Unix File Permissions Explained
To chmod or not to chmod 777, that is the question.
— A wise sysadmin at 3 AM
Welcome to the wild world of Unix file permissions — where three letters decide whether your script runs like a charm or ends up throwing a permission denied error that makes you question your career.
In this guide, we break down those cryptic rwxr-xr--
strings, explain who gets to do what with your files, and sprinkle in some terminal humor.
Meet the Trio: Owner, Group, and Others
Every file in Unix is protected by three types of users:
Who | Description |
---|---|
Owner | The person who created the file |
Group | A team or set of users |
Others | Everyone else on the system |
Each of these roles can be assigned specific powers — the Unix equivalent of magical abilities — using r
, w
, and x
.
The Three Permissions
Symbol | Name | What It Allows You To Do |
---|---|---|
r | Read | View the file contents |
w | Write | Modify or delete the file |
x | Execute | Run the file as a program or script |
So rwx
means full control. rw-
is like “edit but don’t run”, and r--
is “you can look, but don’t touch.”
The Famous Nine: Understanding rwxr-xr–
Here is how a typical permission string looks:
1
-rwxr-xr–
Here’s what each part means:
Position | Characters | Who? | Meaning |
---|---|---|---|
1st | - | File type | - = file, d = directory, l = symlink |
2nd–4th | rwx | Owner | Read, write, execute |
5th–7th | r-x | Group | Read, no write, execute |
8th–10th | r-- | Others | Read only |
So, -rwxr-xr--
means:
- It’s a file (
-
) - The owner can read, write, and execute
- The group can read and execute
- Others can only read
Octal Permissions Cheat Code
Unix uses numbers to represent these permissions:
Permission | Binary | Octal |
---|---|---|
r | 100 | 4 |
w | 010 | 2 |
x | 001 | 1 |
rwx | 111 | 7 |
rw- | 110 | 6 |
r-- | 100 | 4 |
Examples:
chmod 755
meansrwxr-xr-x
chmod 700
meansrwx------
chmod 644
meansrw-r--r--
Common chmod Use Cases
Octal | Symbolic | Description |
---|---|---|
777 | rwxrwxrwx | Everyone can do everything (Nope) |
755 | rwxr-xr-x | Owner full, others can run |
700 | rwx------ | Owner-only access |
644 | rw-r--r-- | Common for config or HTML files |
600 | rw------- | Private data files |
Real Life Permission Scenarios (Cheat Table)
Command | Purpose | Access Level |
---|---|---|
chmod 700 secret.sh | Lock it down — private script or file | Only owner: read, write, execute |
chmod 644 index.html | Public read access — for web files | Owner can edit, others can view |
chmod 755 public/ | Public directory with no write access | Owner full, others can run/view |
chmod 777 party.txt | The Wild West — full access to all | Everyone: read, write, execute |
chmod 664 report.txt | Group collaboration — shared editing | Owner/group edit, others read |
chmod 750 deploy.sh | Executable script for your team | Group can run, only you edit |
chmod 644 terms.pdf | Readable document served publicly | Owner writes, world reads |
chmod 600 diary.txt | Your eyes only — maximum privacy | Only owner can read/write |
chmod 555 run_me.sh | No edits, just execution | All can run, none can edit |
chmod 666 config.yml | Read/write by all, but not executable | Everyone can edit (handle with care) |
Essential Commands Recap
Command | What It Does |
---|---|
ls -l | View file permissions |
chmod | Change file permissions |
chown | Change the file owner |
chgrp | Change the group associated with file |
Visual Reference
flowchart TD
A[Unix File Permissions] --> B[rwxr-xr--]
B --> C1[Owner: rwx]
C1 --> D1[Read (r)]
C1 --> D2[Write (w)]
C1 --> D3[Execute (x)]
B --> C2[Group: r-x]
C2 --> D4[Read (r)]
C2 --> D5[No Write (-)]
C2 --> D6[Execute (x)]
B --> C3[Others: r--]
C3 --> D7[Read (r)]
C3 --> D8[No Write (-)]
C3 --> D9[No Execute (-)]
⸻
Pro Tips
• Do not casually use chmod 777. It’s the nuclear option. • Use groups to manage shared access. • Always verify your umask settings for default file permissions.
References
GNU Coreutils Manual –
chmod
Dive into the official documentation forchmod
, straight from the source:
https://www.gnu.org/software/coreutils/manual/html_node/chmod-invocation.htmlThe Linux Documentation Project – File Permissions
A beginner-friendly explanation of Unix permissions from the classic TLDP guides:
https://tldp.org/LDP/intro-linux/html/sect_03_04.htmlUbuntu Wiki – File Permissions
Another great reference for understanding how permissions work in a real-world Linux distro:
https://help.ubuntu.com/community/FilePermissions