Understanding Linux File Permissions (chmod & chown) for Total Beginners
Welcome back, young explorer!
Today we’re going to unpack something that confuses almost every Linux beginner:
👉 File permissions and ownership
Or in Linux language:
-
chmod -
chown -
rwx -
755,644, etc.
Don’t worry — we’re going to break this down until it feels natural and easy.
Think of this as learning how locks and keys work in your digital house.
Let’s begin.
🧩 Step 1: What Are File Permissions?
In Linux, every file has rules controlling:
1. Who can read it
2. Who can modify it
3. Who can run it
These are known as permissions, represented by:
And they apply to three groups:
Let’s see an example.
Run:
You might see something like:
Breakdown:
| Section | Meaning |
|---|---|
-rw-r--r-- | Permissions |
root | User (owner) |
root | Group |
index.html | File name |
Let’s decode the permission part:
This means:
-
user: read + write
-
group: read
-
others: read
Simple so far, right?
🛠️ Step 2: Changing Permissions with chmod
chmod means change mode — the tool used to change file permissions.
There are two methods:
-
Letter (r, w, x)
-
Number (755, 644)
Let’s start with the beginner-friendly number system.
🔢 Step 3: Understanding Permission Numbers (chmod)
Each permission has a number:
| Permission | Value |
|---|---|
| read (r) | 4 |
| write (w) | 2 |
| execute (x) | 1 |
To assign permissions, you add up the values.
Example:
Read + Write:
→ permission = 6
Read Only:
→ permission = 4
Read + Execute:
→ permission = 5
Full Permissions:
→ permission = 7
So when you see:
Break it down:
-
user: 7 → rwx
-
group: 5 → r-x
-
others: 5 → r-x
This is very common for web apps.
🧪 Step 4: Common chmod Values You Will Use Daily
| Value | Meaning | Use case |
|---|---|---|
| 755 | user: rwx / group: r-x / others: r-x | web directories, scripts |
| 644 | user: rw- / group: r-- / others: r-- | HTML, config files |
| 600 | user: rw- only | SSH keys |
| 700 | user: rwx only | private scripts or folders |
| 777 | everyone can do everything | ❌ avoid! dangerous! |
Setting 755 on a folder:
Setting 644 on a file:
Setting 600 on private key:
👑 Step 5: Changing Ownership with chown
chown means change owner of a file.
Format:
Example: assigning ownership to user www-data:
-R = recursively (apply to all files inside)
When do you use chown?
✔ When installing web apps
✔ When uploading files via FTP
✔ When fixing "Permission denied" errors
✔ When Apache/Nginx cannot read a file
⚠️ Step 6: Fixing Common Permission Problems
❌ Error: Permission denied
Cause: You don’t have permission.
Fix: Allow read/write:
Or change owner:
❌ Nginx/Apache cannot access your site
Give correct web user permissions:
Ubuntu/Debian uses:
CentOS/RHEL uses:
❌ SSH key not working
Your permissions are too open.
Fix:
🎯 Step 7: What Permissions Should You Never Use?
❌ Never use chmod 777
This gives EVERYONE full control.
Hackers LOVE 777.
Don’t give it to them.
❌ Never give write access to “others”
Example:
This is a recipe for disaster.
Stick to safe numbers:
-
644 for files
-
755 for folders
-
600 for private files
🔐 Bonus: Permission Cheat Sheet (Copy & Save!)
🎉 Conclusion
You just learned:
✔ How Linux permissions work
✔ How to understand rwx
✔ How chmod numbers like 755 and 644 work
✔ How to change ownership with chown
✔ How to fix common permission errors
✔ What to avoid (like 777!)
File permissions are fundamental.
After reading this guide, you are now far more comfortable managing secure Linux servers.