{
    "mode": "man",
    "parameter": "CHMOD",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/man/CHMOD/json",
    "generated": "2026-11-10T02:31:30Z",
    "synopsis": "chmod [OPTION]... MODE[,MODE]... FILE...\nchmod [OPTION]... OCTAL-MODE FILE...\nchmod [OPTION]... --reference=RFILE FILE...",
    "sections": {
        "NAME": {
            "content": "chmod - change file mode bits\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "chmod [OPTION]... MODE[,MODE]... FILE...\nchmod [OPTION]... OCTAL-MODE FILE...\nchmod [OPTION]... --reference=RFILE FILE...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This  manual  page  documents  the GNU version of chmod.  chmod changes the file mode bits of\neach given file according to mode, which can be either a symbolic representation  of  changes\nto make, or an octal number representing the bit pattern for the new mode bits.\n\nThe format of a symbolic mode is [ugoa...][[-+=][perms...]...], where perms is either zero or\nmore  letters  from  the  set rwxXst, or a single letter from the set ugo.  Multiple symbolic\nmodes can be given, separated by commas.\n\nA combination of the letters ugoa controls which users' access to the file will  be  changed:\nthe  user who owns it (u), other users in the file's group (g), other users not in the file's\ngroup (o), or all users (a).  If none of these are given, the effect is as if (a) were given,\nbut bits that are set in the umask are not affected.\n\nThe operator + causes the selected file mode bits to be added to the existing file mode  bits\nof  each  file;  - causes them to be removed; and = causes them to be added and causes unmen‐\ntioned bits to be removed except that a directory's unmentioned set user and  group  ID  bits\nare not affected.\n\nThe letters rwxXst select file mode bits for the affected users: read (r), write (w), execute\n(or  search  for  directories) (x), execute/search only if the file is a directory or already\nhas execute permission for some user (X), set user or group ID on execution  (s),  restricted\ndeletion  flag  or  sticky bit (t).  Instead of one or more of these letters, you can specify\nexactly one of the letters ugo: the permissions granted to the user who owns  the  file  (u),\nthe  permissions granted to other users who are members of the file's group (g), and the per‐\nmissions granted to users that are in neither of the two preceding categories (o).\n\nA numeric mode is from one to four octal digits (0-7), derived by adding  up  the  bits  with\nvalues 4, 2, and 1.  Omitted digits are assumed to be leading zeros.  The first digit selects\nthe  set  user  ID (4) and set group ID (2) and restricted deletion or sticky (1) attributes.\nThe second digit selects permissions for the user who owns the file: read (4), write (2), and\nexecute (1); the third selects permissions for other users in the file's group, with the same\nvalues; and the fourth for other users not in the file's group, with the same values.\n\nchmod never changes the permissions of symbolic links; the chmod system  call  cannot  change\ntheir  permissions.   This is not a problem since the permissions of symbolic links are never\nused.  However, for each symbolic link listed on the command line, chmod changes the  permis‐\nsions  of  the pointed-to file.  In contrast, chmod ignores symbolic links encountered during\nrecursive directory traversals.\n",
            "subsections": []
        },
        "SETUID AND SETGID BITS": {
            "content": "chmod clears the set-group-ID bit of a regular file if the file's group ID does not match the\nuser's effective group ID or one of the user's supplementary group IDs, unless the  user  has\nappropriate  privileges.   Additional restrictions may cause the set-user-ID and set-group-ID\nbits of MODE or RFILE to be ignored.  This behavior depends on the policy  and  functionality\nof the underlying chmod system call.  When in doubt, check the underlying system behavior.\n\nFor directories chmod preserves set-user-ID and set-group-ID bits unless you explicitly spec‐\nify otherwise.  You can set or clear the bits with symbolic modes like u+s and g-s.  To clear\nthese  bits  for  directories  with  a  numeric mode requires an additional leading zero like\n00755, leading minus like -6000, or leading equals like =755.\n",
            "subsections": []
        },
        "RESTRICTED DELETION FLAG OR STICKY BIT": {
            "content": "The restricted deletion flag or sticky bit is a single bit, whose interpretation  depends  on\nthe  file  type.  For directories, it prevents unprivileged users from removing or renaming a\nfile in the directory unless they own the file or the  directory;  this  is  called  the  re‐\nstricted deletion flag for the directory, and is commonly found on world-writable directories\nlike  /tmp.   For regular files on some older systems, the bit saves the program's text image\non the swap device so it will load more quickly when run; this is called the sticky bit.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Change the mode of each FILE to MODE.  With --reference, change the mode of each FILE to that\nof RFILE.\n",
            "subsections": [
                {
                    "name": "-c --changes",
                    "content": "like verbose but report only when a change is made\n",
                    "flag": "-c",
                    "long": "--changes"
                },
                {
                    "name": "-f --silent --quiet",
                    "content": "suppress most error messages\n",
                    "flag": "-f",
                    "long": "--quiet"
                },
                {
                    "name": "-v --verbose",
                    "content": "output a diagnostic for every file processed\n",
                    "flag": "-v",
                    "long": "--verbose"
                },
                {
                    "name": "--no-preserve-root",
                    "content": "do not treat '/' specially (the default)\n",
                    "long": "--no-preserve-root"
                },
                {
                    "name": "--preserve-root",
                    "content": "fail to operate recursively on '/'\n\n--reference=RFILE\nuse RFILE's mode instead of specifying MODE values.  RFILE is always dereferenced if a\nsymbolic link.\n",
                    "long": "--preserve-root"
                },
                {
                    "name": "-R --recursive",
                    "content": "change files and directories recursively\n\n--help display this help and exit\n",
                    "flag": "-R",
                    "long": "--recursive"
                },
                {
                    "name": "--version",
                    "content": "output version information and exit\n\nEach MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.\n",
                    "long": "--version"
                }
            ]
        },
        "AUTHOR": {
            "content": "Written by David MacKenzie and Jim Meyering.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "GNU coreutils online help: <https://www.gnu.org/software/coreutils/>\nReport any translation bugs to <https://translationproject.org/team/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2023 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3  or  later\n<https://gnu.org/licenses/gpl.html>.\nThis  is free software: you are free to change and redistribute it.  There is NO WARRANTY, to\nthe extent permitted by law.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "chmod(2)\n\nFull documentation <https://www.gnu.org/software/coreutils/chmod>\nor available locally via: info '(coreutils) chmod invocation'\n\nGNU coreutils 9.4                           January 2026                                    CHMOD(1)",
            "subsections": []
        }
    },
    "summary": "chmod - change file mode bits",
    "flags": [
        {
            "flag": "-c",
            "long": "--changes",
            "arg": null,
            "description": "like verbose but report only when a change is made"
        },
        {
            "flag": "-f",
            "long": "--quiet",
            "arg": null,
            "description": "suppress most error messages"
        },
        {
            "flag": "-v",
            "long": "--verbose",
            "arg": null,
            "description": "output a diagnostic for every file processed"
        },
        {
            "flag": "",
            "long": "--no-preserve-root",
            "arg": null,
            "description": "do not treat '/' specially (the default)"
        },
        {
            "flag": "",
            "long": "--preserve-root",
            "arg": null,
            "description": "fail to operate recursively on '/' --reference=RFILE use RFILE's mode instead of specifying MODE values. RFILE is always dereferenced if a symbolic link."
        },
        {
            "flag": "-R",
            "long": "--recursive",
            "arg": null,
            "description": "change files and directories recursively --help display this help and exit"
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "output version information and exit Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "chmod",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/chmod/2/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Change the access permissions of a file or directory.",
        "examples": [
            {
                "description": "Give the [u]ser who owns a file the right to e[x]ecute it",
                "command": "chmod u+x {{path/to/file}}"
            },
            {
                "description": "Give the [u]ser rights to [r]ead and [w]rite to a file/directory",
                "command": "chmod u+rw {{path/to/file_or_directory}}"
            },
            {
                "description": "Remove e[x]ecutable rights from the [g]roup",
                "command": "chmod g-x {{path/to/file}}"
            },
            {
                "description": "Give [a]ll users rights to [r]ead and e[x]ecute",
                "command": "chmod a+rx {{path/to/file}}"
            },
            {
                "description": "Give [o]thers (not in the file owner's group) the same rights as the [g]roup",
                "command": "chmod o=g {{path/to/file}}"
            },
            {
                "description": "Remove all rights from [o]thers",
                "command": "chmod o= {{path/to/file}}"
            },
            {
                "description": "Change permissions recursively giving [g]roup and [o]thers the ability to [w]rite",
                "command": "chmod {{-R|--recursive}} g+w,o+w {{path/to/directory}}"
            },
            {
                "description": "Recursively give [a]ll users [r]ead permissions to files. Also give e[X]ecute permissions to files that have at least one execution permission and to all sub-directories",
                "command": "chmod {{-R|--recursive}} a+rX {{path/to/directory}}"
            }
        ]
    }
}