Explain file permissions in Linux (rwx, octal notation) and when to use sticky bit/setuid.
Linux file permissions have three sets: owner, group, others. Each can have: read (4), write (2), execute (1).
-rwxr-xr-- = 754
# Owner: rwx (7), Group: r-x (5), Others: r-- (4)
chmod 755 script.sh # Standard executable
chmod 644 config.yml # Standard config file
Special bits:
- Sticky bit (1xxx): On directories (e.g.,
/tmp), only the file owner can delete their own files:chmod +t /shared - Setuid (4xxx): File executes with the owner’s permissions (used by
/usr/bin/passwdto write/etc/shadowas root). Use with extreme caution.