About Linux File Permissions
The 3 Base Classes
Linux permissions apply to three classes: Owner (the user who created it), Group (users assigned to the file's group), and Public/Others (everyone else on the system). Each class is granted Read (4), Write (2), and Execute (1) rights.
Special Permissions
Advanced security rules are governed by a 4th leading digit. SUID (4) allows execution as the file owner. SGID (2) runs files as the group owner, and Sticky Bit (1) protects shared directory files from deletion by non-owners.
Frequently Asked Questions
What does chmod 777 mean?
chmod 777 grants Read, Write, and Execute permissions to the Owner, the Group, and Public (Others). It is a massive security risk because it allows anyone on the system, or anyone accessing a web server, to modify or execute a file. It should generally be avoided in production environments.
What is the difference between chmod 755 and 644?
755 and 644 are the most common web-hosting permissions. 755 is used for directories (granting read/execute to the public so they can list/enter the folder). 644 is used for files (granting read access to the public but preventing them from executing or modifying the file).
What is the Sticky Bit (chmod 1000)?
The Sticky Bit is a special permission most commonly applied to shared directories like /tmp. When set, it ensures that only the file's owner (or the root user) can rename or delete files within that directory, even if other users have write access to the folder. In symbolic notation, it modifies the public execute bit to a t or T.
What is SUID and SGID?
SUID (Set User ID) allows a file to be executed with the privileges of the file's owner, rather than the user running it. SGID (Set Group ID) allows a file to be executed with the privileges of the file's group. They are powerful tools but must be used carefully to avoid privilege escalation vulnerabilities. They appear as an s or S in the symbolic string.