Linux File Permissions: The Visual Guide

Understand chmod, chown, and rwx permissions visually. Mastering user, group, and world access control in Linux.

Linux File Permissions: The Visual Guide
📧

Get weekly IT guides

Join 5,000+ IT professionals

Subscribe Free

“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

What You'll Learn
  • How to read drwxr-xr-x (it’s not gibberish)
  • What User, Group, and Other mean
  • How to use chmod numerically (777 vs 644)
  • Why you should never use 777
Mental Model: The Office Building

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:

Permission String Parsing Diagram
Permission String Breakdown

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
Octal Math Calculation Diagram
Octal Math: How 4+2+1 Works

Key Commands: chmod & chown

1. chmod (Change Mode)

Changes permissions.

chmod 644 myfile.txt

Set User=RW, Group=R, Other=R (Standard for files)

beginner
myfile.txt permissions updated
chmod +x script.sh

Make a script executable (add 'x' to everyone)

beginner
./script.sh runs successfully

2. chown (Change Owner)

Changes who owns the file.

sudo chown shekhar:devs myfile.txt

Change owner to 'shekhar' and group to 'devs'

beginner
changed ownership of 'myfile.txt' to shekhar:devs

Why 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

NeedCodeDescription
Web Server Files644Owner writes, world reads (HTML/CSS).
Private Keys (SSH)600Only owner reads/writes. STRICT.
Scripts755Owner writes/runs, world reads/runs.
Shared Folder770Owner & 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.
You Now Know

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

Found this helpful? Explore more in the Linux Hub!

📧

Get weekly IT guides

Join 5,000+ IT professionals

Subscribe Free
Type to start searching...