3. Permissions, users and privilege
One-liner. Unix permissions are a coarse allow-list; capabilities and ACLs are the precision tools.
Memorize
- Mode bits: owner / group / other ×
rwx; execute on a directory means traverse, read means list. - umask masks new-file permissions (default
022→ 644 files, 755 dirs). - setuid/setgid run with the file owner's/group's identity — a common privilege-escalation source.
- sticky bit on
/tmplets only the owner delete their files. - ACLs (
getfacl/setfacl) grant per-user/per-group rights; capabilities (cap_net_bind_service) split root into pieces. sudochecks/etc/sudoers(usevisudo);sudo -lshows what you may run.- Never run services as root by default:
User=,NoNewPrivileges=,ProtectSystem=strict.
Trap. chmod 777 to "fix" access — it grants write to everyone and often disables security controls. Do this. Fix ownership/group and use 750/640; add an ACL for the one extra user.
Check
A directory has mode 750 and is owned by app:deploy. A user in group deploy can do what?
Why
Group bits are r-x: listing requires r, entering requires x, and creating requires w, which is absent.