SUID, SGID, Sticky & umask

Special Permission Bits

BitOctalOn a fileOn a directory
SUID4000Runs as file owner (e.g. passwd)-
SGID2000Runs as file groupNew files inherit the dir's group
Sticky1000-Only the owner can delete their files (e.g. /tmp)
$ ls -l /usr/bin/passwd
-rwsr-xr-x 1 root root 59976 /usr/bin/passwd   # s = SUID
$ ls -ld /tmp
drwxrwxrwt 10 root root 4096 /tmp              # t = sticky

Set them: chmod 4755 file (SUID), chmod 2775 dir (SGID), chmod +t dir (sticky).

umask

umask subtracts permissions from the defaults (666 files, 777 dirs) for newly created files.

umask 022  →  files 644, dirs 755   (typical default)
umask 077  →  files 600, dirs 700   (private)
Exam tip: ACLs (getfacl/setfacl) grant permissions beyond the basic three classes, e.g. setfacl -m u:bob:rw file. A + at the end of ls -l permissions means an ACL is present.