DEV Community

Sreekanth Kuruba
Sreekanth Kuruba

Posted on

Linux File Permissions Explained Simply

Ever ran a Linux command and saw this?

Permission denied

It feels random at first — but it’s not.

That error is Linux protecting your system using file permissions.

Once you understand this, Linux security suddenly starts making sense.


What Are Linux File Permissions?

Every file and directory has three types of permissions:

  • Read (r) → View file content
  • Write (w) → Modify or delete file
  • Execute (x) → Run file as a program/script

👉 These decide what you are allowed to do with a file.


3 Types of Users in Linux

Permissions are not just for files — they are for users.

User Type Symbol Meaning
Owner u The owner of the file
Group g Users in the same group
Others o Everyone else

👉 Linux is a multi-user system, so access control is essential.


Understanding ls -l (Very Important)

Run this command:

ls -l
Enter fullscreen mode Exit fullscreen mode

Example output:

-rwxr-xr-- 1 user group  1024 Apr 10 12:34 script.sh
Enter fullscreen mode Exit fullscreen mode

Now it Breakdown:

  • First character → - = file, d = directory
  • Next 3 → Owner permissions
  • Next 3 → Group permissions
  • Last 3 → Others permissions

Permission Symbols

Symbol Meaning
r Read
w Write
x Execute
- No permission

Changing Permissions chmod

Make script executable

chmod +x script.sh
Enter fullscreen mode Exit fullscreen mode

Numeric method (very common in servers)

chmod 755 script.sh
Enter fullscreen mode Exit fullscreen mode

Numeric permissions are a shortcut to set all three permission types at once.


Common Numeric Permissions:

Number Permission Meaning
7 rwx Read + Write + Execute
6 rw- Read + Write
5 r-x Read + Execute
4 r-- Read only

👉 So:

755 = rwx r-x r-x
Enter fullscreen mode Exit fullscreen mode

Owner → full access
Group → read + execute
Others → read + execute


Change Owner (chown)

chown username file.txt
chown user:group file.txt  
Enter fullscreen mode Exit fullscreen mode

Recursive:

chown -R user:group folder/
Enter fullscreen mode Exit fullscreen mode

Only the root user or sudo user can change ownership.

Changing Group (chgrp)

chgrp developers project/
Enter fullscreen mode Exit fullscreen mode

Used when:

multiple developers work on same project
shared access is needed


⚠️ Dangerous Mistake Beginners Make

chmod 777 file.txt     # ❌ Very Dangerous
Enter fullscreen mode Exit fullscreen mode

🚨 This gives:

full access to everyone
no security control
breaks Linux permission model

👉 Never use this in real servers.


Real-Life Example

You create a script:

./script.sh
Enter fullscreen mode Exit fullscreen mode

And get:

Permission denied
Enter fullscreen mode Exit fullscreen mode

Fix:

chmod +x script.sh
./script.sh
Enter fullscreen mode Exit fullscreen mode

👉 This is one of the most common Linux beginner issues.


Simple Mental Model

Think of Linux permissions like a building:

Owner → has master key
Group → shared access card
Others → guest access

And:

r → can look inside
w → can modify
x → can enter/run

Summary

You learned:

  • What r, w, x mean
  • User types (owner, group, others)
  • How to read ls -l
  • Using chmod
  • Numeric permissions (755, 644, etc.)
  • Changing ownership with chown
  • Changing groups with chgrp
  • Why chmod 777 is dangerous

Why This Matters

File permissions are not just theory.

They are used in:

Linux servers
DevOps pipelines
Docker containers
Cloud systems
Production deployments

👉 If you understand this, you understand Linux security basics.


Next Post:

Linux User & Group Management Explained Simply,useradd, usermod, groups


Which permission concept confused you the most when you first used Linux?

I’ll simplify it even further in Part 4.

Top comments (0)