CHMOD(1)

๐Ÿ’… CHMOD(1) โ€” the chmod manual, but make it a group chat ๐Ÿ’…

okay bestie so you found the chmod page and honestly? iconic. this is the GNU version of chmod and it's about to be your new obsession. let's get into it ๐ŸŽ€


โœจ NAME โœจ

chmod โ€” change file mode bits

like literally. it changes the permission bits. that's the whole vibe. ๐Ÿ’–


๐ŸŒธ SYNOPSIS ๐ŸŒธ

chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...

three whole ways to do it, pick your fighter ๐Ÿซถ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so this page documents the GNU version of chmod, and what chmod does is change the file mode bits of every file you hand it, according to mode. and mode can be either:

  • a symbolic representation of the changes you want to make, or
  • an octal number that represents the bit pattern of the new mode bits. ๐ŸŽ€

the symbolic mode format, explained with love ๐Ÿ’œ

the format of a symbolic mode is:

[ugoa...][[-+=][perms...]...]

and perms is either zero or more letters from the set rwxXst, or a single letter from the set ugo. you can stack multiple symbolic modes and separate them with commas. no cap. โœจ

a combination of the letters ugoa controls which users' access to the file gets changed:

  • u โ€” the user who owns it
  • g โ€” other users in the file's group
  • o โ€” other users not in the file's group
  • a โ€” all users

and if you give none of them, the effect is as if you'd given a, except bits that are set in the umask are not affected. sneaky but true ๐Ÿ™ˆ

now the operators, because this is where it gets good:

  • + โ€” causes the selected file mode bits to be added to the existing file mode bits of each file
  • - โ€” causes them to be removed
  • = โ€” causes them to be added and causes unmentioned bits to be removedโ€ฆ with the exception that a directory's unmentioned set user and group ID bits are not affected ๐Ÿ‘‘

the permission letters ๐Ÿงš

the letters rwxXst select file mode bits for the affected users:

  • r โ€” read
  • w โ€” write
  • x โ€” execute (or search, for directories)
  • X โ€” execute/search only if the file is a directory or already has execute permission for some user
  • s โ€” set user or group ID on execution
  • t โ€” restricted deletion flag or sticky bit

and instead of one or more of those letters, you can specify exactly one of the letters ugo:

  • u โ€” the permissions granted to the user who owns the file
  • g โ€” the permissions granted to other users who are members of the file's group
  • o โ€” the permissions granted to users that are in neither of the two preceding categories

the numeric mode, aka the numbers girlies ๐Ÿ“

a numeric mode is from one to four octal digits (0-7), derived by adding up the bits with values 4, 2, and 1. any digits you omit are assumed to be leading zeros. here's the breakdown:

  • the first digit selects the set user ID (4), set group ID (2), and restricted deletion or sticky (1) attributes
  • the second digit selects permissions for the user who owns the file: read (4), write (2), and execute (1)
  • the third digit selects permissions for other users in the file's group, same values
  • the fourth digit is for other users not in the file's group, same values

slay. memorize it. it's giving octal ๐Ÿ’…

chmod doesn't change the permissions of symbolic links.

and that's not a choice, bestie โ€” the chmod system call cannot change their permissions on most systems, and most systems just ignore permissions of symbolic links. periodt.

however (and this is the plot twist): for each symbolic link listed on the command line, chmod changes the permissions of the pointed-to file. in contrast, chmod ignores symbolic links encountered during recursive directory traversals. the options that modify this behavior are described down in the OPTIONS section ๐Ÿ‘€


๐Ÿ‘‘ SETUID AND SETGID BITS ๐Ÿ‘‘

okay this part is serious so pay attention:

chmod clears the set-group-ID bit of a regular file if the file's group ID does not match the user's effective group ID or one of the user's supplementary group IDs โ€” unless the user has appropriate privileges. ๐Ÿ’€

also, additional restrictions may cause the set-user-ID and set-group-ID bits of MODE or RFILE to be ignored. this behavior depends on the policy and functionality of the underlying chmod system call. so when in doubt? check the underlying system behavior. fr fr.

for directories, chmod preserves set-user-ID and set-group-ID bits unless you explicitly specify otherwise. you can set or clear the bits with symbolic modes like u+s and g-s. but to clear these bits for directories with a numeric mode you need one of these:

  • an additional leading zero like 00755
  • a leading minus like -6000
  • a leading equals like =755

that's the trick, iykyk โœจ


๐ŸŒˆ RESTRICTED DELETION FLAG OR STICKY BIT ๐ŸŒˆ

the restricted deletion flag or sticky bit is a single bit, and its interpretation depends on the file type. main character energy honestly.

  • for directories, it prevents unprivileged users from removing or renaming a file in the directory unless they own the file or the directory. this is called the restricted deletion flag for the directory, and it's commonly found on world-writable directories like /tmp. ๐ŸŽ€
  • for regular files on some older systems, the bit saves the program's text image on the swap device so it will load more quickly when run. this is called the sticky bit.

๐Ÿ’– OPTIONS ๐Ÿ’–

change the mode of each FILE to MODE. with --reference, change the mode of each FILE to that of RFILE. let's go one by one, bestie ๐Ÿซถ

  • -c, --changes โ€” like verbose but report only when a change is made ๐Ÿ‘€
  • -f, --silent, --quiet โ€” suppress most error messages (shhh ๐Ÿ™ˆ)
  • -v, --verbose โ€” output a diagnostic for every file processed ๐Ÿ’ฌ
  • --dereference โ€” affect the referent of each symbolic link, rather than the symbolic link itself
  • -h, --no-dereference โ€” affect each symbolic link, rather than the referent
  • --no-preserve-root โ€” do not treat / specially (the default)
  • --preserve-root โ€” fail to operate recursively on / โš ๏ธ
  • --reference=RFILE โ€” use RFILE's mode instead of specifying MODE values. RFILE is always dereferenced if a symbolic link.
  • -R, --recursive โ€” change files and directories recursively ๐ŸŒ€

the following options modify how a hierarchy is traversed when the -R option is also specified. if more than one is specified, only the final one takes effect. and -H is the default. ๐Ÿ“Œ

  • -H โ€” if a command line argument is a symlink to a directory, traverse it
  • -L โ€” traverse every symbolic link to a directory encountered
  • -P โ€” do not traverse any symbolic links

and the last two babies:

  • --help โ€” display this help and exit ๐ŸŒŸ
  • --version โ€” output version information and exit
each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'. write that down bestie, that's the whole grammar ๐Ÿ’…

๐ŸŽ€ AUTHOR ๐ŸŽ€

written by David MacKenzie and Jim Meyering. legends, honestly. thank you for your service ๐Ÿซก๐Ÿ’–


โš ๏ธ REPORTING BUGS โš ๏ธ

found a bug? not you being the detective ๐Ÿ” report it, don't just tweet about it:


Copyright ยฉ 2026 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.

this is free software: you are free to change and redistribute it.

There is NO WARRANTY, to the extent permitted by law. ๐Ÿ˜ญ (read it. it matters.)

๐ŸŒŸ SEE ALSO ๐ŸŒŸ

full documentation <https://www.gnu.org/software/coreutils/chmod> or available locally via: info '(coreutils) chmod invocation'


and that's the page, bestie ๐Ÿ’…โœจ GNU coreutils 9.12, from September 2026, and this whole thing is the CHMOD(1) page of the User Commands manual. now go fix your permissions. you're gonna eat. ๐Ÿซถ๐Ÿ’–๐ŸŽ€

๐Ÿ“ฆ where this page comes from