Special Permission Bits: SUID, SGID, and Sticky
You'll learn how special permission bits modify file execution behavior and why they require careful security oversight.
Beyond standard read/write/execute permissions, Linux provides three special permission bits that alter how processes and users interact with files and directories.
What Are Special Permission Bits?
Think of special permission bits as "VIP passes" that temporarily grant extra privileges or enforce special rules:
SUID (Set User ID): When set on an executable file, the process runs with the file owner's privileges instead of the executing user's privileges. For example, the passwd command needs SUID to modify /etc/shadow even when run by regular users.
SGID (Set Group ID): On executables, processes run with the file's group privileges. On directories, newly created files inherit the directory's group rather than the creator's primary group—useful for shared project folders.
Sticky Bit: On directories (like /tmp), only the file owner can delete their own files, preventing users from deleting others' files even with write permission to the directory.
Security Implications
These bits are powerful but dangerous:
- SUID vulnerabilities can grant root access if exploitable (e.g., buffer overflows in SUID-root binaries)
- Unnecessary SUID/SGID files expand attack surface
- World-writable SUID programs are especially risky
- Attackers actively hunt for misconfigured special bits
Proper Usage
Find SUID files: find / -perm -4000 -type f 2>/dev/null
Set SUID: chmod u+s filename or chmod 4755 filename
Remove SUID: chmod u-s filename
Regularly audit special permission bits, minimize their use to essential system utilities only, and never set SUID on user scripts or world-writable files.
Key Takeaway: Special permission bits are powerful privilege-escalation mechanisms that must be strictly controlled—audit regularly and apply only where absolutely necessary.