Reading permissions
Each file has three sets of permissions — owner, group and everyone else — and each set has read (4), write (2) and execute (1). Add the numbers for each set to get the octal digit:
rwx = 4+2+1 = 7 r-x = 4+0+1 = 5 r-- = 4+0+0 = 4 rwxr-xr-x = 755 rw-r--r-- = 644
Directories
On a directory, read lets you list it, write lets you create and delete files in it, and execute lets you enter it (cd) and reach files inside. Directories almost always need execute wherever they have read.
Special bits
- setuid (4000): a program runs as its owner — how passwd changes system files.
- setgid (2000): on a directory, new files inherit its group.
- sticky (1000): on a directory, only a file’s owner can delete it.