{
    "content": [
        {
            "type": "text",
            "text": "# chmod(1) (man)\n\n**Summary:** chmod - change file mode bits\n\n**Synopsis:** chmod [OPTION]... MODE[,MODE]... FILE...\nchmod [OPTION]... OCTAL-MODE FILE...\nchmod [OPTION]... --reference=RFILE FILE...\n\n## Flags\n\n| Flag | Long | Arg | Description |\n|------|------|-----|-------------|\n| -c | --changes | — | like verbose but report only when a change is made |\n| -f | --quiet | — | suppress most error messages |\n| -v | --verbose | — | output a diagnostic for every file processed |\n| — | --no-preserve-root | — | do not treat '/' specially (the default) |\n| — | --preserve-root | — | fail to operate recursively on '/' --reference=RFILE use RFILE's mode instead of MODE values |\n| -R | --recursive | — | change files and directories recursively --help display this help and exit |\n| — | --version | — | output version information and exit Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'. |\n\n## Section Outline\n\n- **NAME** (2 lines)\n- **SYNOPSIS** (4 lines)\n- **DESCRIPTION** (39 lines)\n- **SETUID AND SETGID BITS** (11 lines)\n- **RESTRICTED DELETION FLAG OR STICKY BIT** (7 lines)\n- **OPTIONS** (3 lines) — 7 subsections\n  - -c --changes (2 lines)\n  - -f --silent --quiet (2 lines)\n  - -v --verbose (2 lines)\n  - --no-preserve-root (2 lines)\n  - --preserve-root (5 lines)\n  - -R --recursive (4 lines)\n  - --version (4 lines)\n- **AUTHOR** (2 lines)\n- **REPORTING BUGS** (3 lines)\n- **COPYRIGHT** (5 lines)\n- **SEE ALSO** (8 lines)\n\n## Full Content\n\n### NAME\n\nchmod - change file mode bits\n\n### SYNOPSIS\n\nchmod [OPTION]... MODE[,MODE]... FILE...\nchmod [OPTION]... OCTAL-MODE FILE...\nchmod [OPTION]... --reference=RFILE FILE...\n\n### DESCRIPTION\n\nThis  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\n### SETUID AND SETGID BITS\n\nchmod 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, or  lead‐\ning = like 00755 , or =755\n\n### RESTRICTED DELETION FLAG OR STICKY BIT\n\nThe  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\n### OPTIONS\n\nChange the mode of each FILE to MODE.  With --reference, change the mode of each FILE to that\nof RFILE.\n\n#### -c --changes\n\nlike verbose but report only when a change is made\n\n#### -f --silent --quiet\n\nsuppress most error messages\n\n#### -v --verbose\n\noutput a diagnostic for every file processed\n\n#### --no-preserve-root\n\ndo not treat '/' specially (the default)\n\n#### --preserve-root\n\nfail to operate recursively on '/'\n\n--reference=RFILE\nuse RFILE's mode instead of MODE values\n\n#### -R --recursive\n\nchange files and directories recursively\n\n--help display this help and exit\n\n#### --version\n\noutput version information and exit\n\nEach MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.\n\n### AUTHOR\n\nWritten by David MacKenzie and Jim Meyering.\n\n### REPORTING BUGS\n\nGNU coreutils online help: <https://www.gnu.org/software/coreutils/>\nReport any translation bugs to <https://translationproject.org/team/>\n\n### COPYRIGHT\n\nCopyright  ©  2020 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\n### SEE ALSO\n\nchmod(2)\n\nFull documentation <https://www.gnu.org/software/coreutils/chmod>\nor available locally via: info '(coreutils) chmod invocation'\n\n\n\nGNU coreutils 8.32                          January 2026                                    CHMOD(1)\n\n"
        }
    ],
    "structuredContent": {
        "command": "chmod",
        "section": "1",
        "mode": "man",
        "summary": "chmod - change file mode bits",
        "synopsis": "chmod [OPTION]... MODE[,MODE]... FILE...\nchmod [OPTION]... OCTAL-MODE FILE...\nchmod [OPTION]... --reference=RFILE FILE...",
        "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 MODE values"
            },
            {
                "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": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 39,
                "subsections": []
            },
            {
                "name": "SETUID AND SETGID BITS",
                "lines": 11,
                "subsections": []
            },
            {
                "name": "RESTRICTED DELETION FLAG OR STICKY BIT",
                "lines": 7,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 3,
                "subsections": [
                    {
                        "name": "-c --changes",
                        "lines": 2,
                        "flag": "-c",
                        "long": "--changes"
                    },
                    {
                        "name": "-f --silent --quiet",
                        "lines": 2,
                        "flag": "-f",
                        "long": "--quiet"
                    },
                    {
                        "name": "-v --verbose",
                        "lines": 2,
                        "flag": "-v",
                        "long": "--verbose"
                    },
                    {
                        "name": "--no-preserve-root",
                        "lines": 2,
                        "long": "--no-preserve-root"
                    },
                    {
                        "name": "--preserve-root",
                        "lines": 5,
                        "long": "--preserve-root"
                    },
                    {
                        "name": "-R --recursive",
                        "lines": 4,
                        "flag": "-R",
                        "long": "--recursive"
                    },
                    {
                        "name": "--version",
                        "lines": 4,
                        "long": "--version"
                    }
                ]
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "REPORTING BUGS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "COPYRIGHT",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 8,
                "subsections": []
            }
        ]
    }
}