DevToolsForYou

chmod & File Permissions Cheatsheet

A quick reference for Unix file permissions — numeric (octal) and symbolic modes, common permission patterns, and special bits.

Updated Apr 11, 2026

Sections

  1. Permission Bits
  2. Octal Notation
  3. Common Permission Patterns
  4. Symbolic Mode
  5. Special Bits
  6. Viewing & Changing Permissions

Permission Bits

BitOctalSymbolicMeaning
Read4rView file contents / list directory
Write2wModify file / create & delete in directory
Execute1xRun as program / enter directory
None0-No permission

Octal Notation

Three octal digits represent permissions for owner (u), group (g), and others (o). Each digit is the sum of read (4), write (2), execute (1).

OctalPermissionsBinary
7rwx111
6rw-110
5r-x101
4r--100
3-wx011
2-w-010
1--x001
0---000

Common Permission Patterns

OctalSymbolicTypical Use
755rwxr-xr-xDirectories, executables — owner can write, others can read & execute
644rw-r--r--Regular files — owner can write, others read-only
600rw-------Private files — SSH private keys, .env files
700rwx------Private directories or executables
777rwxrwxrwxFully open — avoid in production; only for temp dirs
666rw-rw-rw-Writable by everyone — avoid
444r--r--r--Read-only for everyone
400r--------Owner read-only — common for SSH private keys
775rwxrwxr-xShared project dirs — owner & group can write
664rw-rw-r--Shared files — owner & group can write

Symbolic Mode

SyntaxExampleDescription
u+xchmod u+x fileAdd execute for owner
g-wchmod g-w fileRemove write from group
o=rchmod o=r fileSet others to read-only (exactly)
a+xchmod a+x fileAdd execute for all (owner, group, others)
u=rwx,go=rxchmod u=rwx,go=rx fileOwner full, group and others read+execute
+xchmod +x fileAdd execute for all (shorthand for a+x)
-Rchmod -R 755 dir/Apply recursively to directory and contents

Special Bits

BitOctalSymbolicEffect
Setuid (SUID)4xxxu+sExecute as the file owner — e.g. chmod 4755 (rwsr-xr-x)
Setgid (SGID)2xxxg+sExecute as the group owner; new files in dir inherit group
Sticky bit1xxx+tOnly owner can delete files in directory — e.g. /tmp (rwxrwxrwt)

Viewing & Changing Permissions

CommandDescription
ls -lList files with permission strings (e.g. -rw-r--r--)
stat fileShow detailed file info including octal permissions
chmod 644 fileSet permissions using octal
chmod u+x fileSet permissions using symbolic mode
chmod -R 755 dir/Recursively set permissions on a directory
chown user:group fileChange file owner and group
chown -R user:group dir/Recursively change owner and group
umaskShow default permission mask (subtracted from 666/777 on new files/dirs)
umask 022Set umask — new files get 644, new dirs get 755