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 itgโ other users in the file's groupoโ other users not in the file's groupaโ 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โ readwโ writexโ execute (or search, for directories)Xโ execute/search only if the file is a directory or already has execute permission for some usersโ set user or group ID on executiontโ 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 filegโ the permissions granted to other users who are members of the file's groupoโ 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 ๐
symlinks, the messy part ๐ญ
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:
- report bugs to: <bug-coreutils@gnu.org>.
- report any translation bugs to: <https://translationproject.org/team/>.
- GNU coreutils home page: <https://www.gnu.org/software/coreutils/>
- general help using GNU software: <https://www.gnu.org/gethelp/>
๐ COPYRIGHT ๐
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
- arch rolling: coreutils 9.12-2 ยท GPL-3.0-or-later AND GFDL-1.3-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms