Understanding Unix File Permissions with Octal Notation
Unix/Linux file permissions control who can read, write, and execute files. The octal (base-8) notation — like chmod 755 — is the most common way to set permissions.
Permission bits: Each file has three permission sets for three user categories: - Owner (user): The file's creator - Group: Members of the file's group - Others: Everyone else
Permission values: - Read (r) = 4 - Write (w) = 2 - Execute (x) = 1
These values are added together. 7 = 4+2+1 = rwx (read, write, execute). 5 = 4+1 = r-x (read, execute). 6 = 4+2 = rw- (read, write).
Common permission codes:
| Octal | Symbolic | Meaning |
|---|---|---|
| 755 | rwxr-xr-x | Owner: full access. Group/others: read+execute |
| 644 | rw-r--r-- | Owner: read+write. Group/others: read-only |
| 700 | rwx------ | Owner only: full access. No access for anyone else |
| 777 | rwxrwxrwx | Everyone: full access (security risk — avoid) |
| 600 | rw------- | Owner only: read+write (private files) |
How to use: chmod 755 script.sh makes the file executable for everyone and writable only by the owner — the standard permission for scripts and programs. chmod 644 document.txt makes it readable by everyone but writable only by the owner — standard for web files.
Use Tooler's Number Base Converter to convert between octal, binary, and decimal when working with Unix permissions.