chmod tutorial / cheat sheet / cheatsheet / for dummies
// Octal permissions: decimal, binary, 3-letter, English
0 = 000 = --- = none
1 = 001 = --x = execute (x)
2 = 010 = -w- = write (w)
4 = 100 = r-- = read (r)
// Combinations of the base octal permissions
3 = 011 = -wx = execute + write (1 + 2)
5 = 101 = r-x = execute + read (1 + 4)
6 = 110 = rw- = write + read (2 + 4)
7 = 111 = rwx = execute + write + read (1 + 2 + 4)
// Examples of chmod commands and resulting permissions
12 = r--r--r-- = chmod 444 filename = owner:r-- / group:r-- / others:r--
14 = rw-r--r-- = chmod 644 filename = owner:rw- / group:r-- / others:r--
15 = rwxr--r-- = chmod 744 filename = owner:rwx / group:r-- / others:r--
16 = rw-rw-r-- = chmod 664 filename = owner:rw- / group:rw- / others:r--
17 = rwxrw-r-- = chmod 764 filename = owner:rwx / group:rw- / others:r--
18 = rw-rw-rw- = chmod 666 filename = owner:rw- / group:rw- / others:rw-
19 = rwxrw-rw- = chmod 766 filename = owner:rwx / group:rw- / others:rw-
// Chmod operators // Chmod who values
+ add u User/owner
- remove g Group
= equals o Others/world
, delimiter a All of the above
// Examples of use of operators on files
chmod go= filename : assign group and others no permissions (none)
chmod g=r filename : assign group read (only)
chmod u+wx filename : add write and excute to owner
chmod a-x filename : remove excute from all users
chmod a=r filename : assign read (only) to all users
chmod -R a-w * : remove write from all recursively in current folder
chmod -R a-w+r foldername : remove write, add read to all recursively
chmod u=rwx,g=rx,o= foldername : assign owner:rwx, group:r-x, others:---