“Permission Denied.”
Every Linux user hates this message. But it’s the reason Linux is so secure. Unlike Windows (historically), Linux was built for multi-user systems from Day 1.
Introduction
- How to read
drwxr-xr-x(it’s not gibberish) - What User, Group, and Other mean
- How to use
chmodnumerically (777 vs 644) - Why you should never use
777
Imagine an office building with secure rooms.
- User (u): Only YOU have the key to your private office. (Owner)
- Group (g): The “Marketing Team” has keys to the conference room. (Team)
- Other (o): The public/visitors can only walk in the lobby. (Everyone else)
The permissions are the actions they can take:
- Read (r): Look through the window.
- Write (w): Go inside and rearrange furniture.
- Execute (x): Open the door and enter (for directories) or run a program (for files).
Decoding the Matrix: ls -l
When you type ls -l, you see this:
drwxr-xr-x 2 root root 4096 Feb 11 12:00 myfolder
Let’s break it down:
The Numerical System (Octal)
Computers prefer numbers.
- Read (r) = 4
- Write (w) = 2
- Execute (x) = 1
- No Permission (-) = 0
You sum them up:
- 7 (4+2+1) = Read + Write + Execute (Full Control)
- 6 (4+2) = Read + Write (Modify but don’t run)
- 5 (4+1) = Read + Execute (View and Enter)
- 4 (4) = Read Only
- 0 = No Access
Key Commands: chmod & chown
1. chmod (Change Mode)
Changes permissions.
Set User=RW, Group=R, Other=R (Standard for files)
myfile.txt permissions updatedMake a script executable (add 'x' to everyone)
./script.sh runs successfully2. chown (Change Owner)
Changes who owns the file.
Change owner to 'shekhar' and group to 'devs'
changed ownership of 'myfile.txt' to shekhar:devsWhy NOT chmod 777?
chmod 777 gives everyone access to write.
It’s like leaving your house keys under the mat with a neon sign pointing to them.
Any user (or hacker) on the system can delete or modify your file.
Use 644 for files and 755 for directories instead.
Common Scenarios
| Need | Code | Description |
|---|---|---|
| Web Server Files | 644 | Owner writes, world reads (HTML/CSS). |
| Private Keys (SSH) | 600 | Only owner reads/writes. STRICT. |
| Scripts | 755 | Owner writes/runs, world reads/runs. |
| Shared Folder | 770 | Owner & Group full access, others none. |
Key Takeaways
- User, Group, Other refer to who controls access.
- Read (4), Write (2), Execute (1) refer to what they can do.
- chmod changes permissions; chown changes ownership.
- Never use 777 in production.
Next time you see “Permission Denied”, you know exactly which number (chmod) to use!
Quiz: Test Your Knowledge
Test Your Knowledge
Take a quick 4-question quiz to check your understanding.
Next Steps
- What is Linux? (Pillar)
- Linux Basic Commands (Next Step)
Found this helpful? Explore more in the Linux Hub!