Permissions in Linux
Special Permissions
Section titled “Special Permissions”Special permissions add extra behavior beyond normal rwx rights:
- setuid: Executable runs as the file owner.
- setgid: Executable runs as the file’s group; directories enforce group inheritance.
- sticky bit: In a directory, only root, the file owner, or the directory owner can delete/rename files—even if others have
777.
Symbolic vs Numeric Notation
Section titled “Symbolic vs Numeric Notation”- Symbolic:
u+s,g+s,+t - Numeric: First digit in
chmodrepresents special bits:4= setuid2= setgid1= sticky bit
- Combine them by addition:
chmod 4755 file→ setuid +rwxr-xr-xchmod 2755 dir→ setgid +rwxr-xr-xchmod 1755 dir→ sticky +rwxr-xr-xchmod 6755 file→ setuid + setgid +rwxr-xr-x
Permission Table
Section titled “Permission Table”| Special Bit | Effect | Symbolic | Numeric | Example Command | Example ls -l Output |
|---|---|---|---|---|---|
| setuid | Executable runs with owner’s UID | u+s | 4000 | chmod 4755 /usr/bin/sudo | ---s--x--x. 1 root root ... /usr/bin/sudo |
| setgid | Executable runs with file’s GID; directories enforce group inheritance | g+s | 2000 | chmod 2555 /usr/bin/wall | -r-xr-sr-x. 1 root tty ... /usr/bin/wall |
| sticky bit | In directory: only root, file owner, or dir owner can delete/rename files | +t | 1000 | chmod 1777 /tmp | drwxrwxrwt. 11 root root ... /tmp |
✅ Quick Visual for Numeric Notation
Section titled “✅ Quick Visual for Numeric Notation”chmod [special][owner][group][others] ^ ^ ^ ^ | | | | | | | └─ others permissions (rwx) | | └──────── group permissions (rwx) | └─────────────── owner permissions (rwx) └─────────────────────── special bits (4=setuid, 2=setgid, 1=sticky)✅ Key Points
Section titled “✅ Key Points”- Sticky bit only affects deletion/rename, not read/write/execute.
sreplacesxin user/group execute position when setuid/setgid is active.treplacesxin others execute position when sticky bit is active.