Understanding Linux File Permissions: A Visual Guide

Search for a command to run...

No comments yet. Be the first to comment.
🎬 The Story Picture this: You push code to GitHub. Five minutes later, your updated application is running in production—built, scanned for vulnerabilities, containerized, and deployed automatically. No manual steps. No human errors. Pure automation...
Building a Production-Ready GitOps CI/CD Pipeline: How Modern Companies Deploy Code 1000+ Times Per Day From Manual Deployments to Netflix-Level Automation 12 min read • DevOps • Cloud Native • Automation 🎯 The Problem Every Developer Faces Pictur...
When most people open VIM for the first time, the reaction is almost universal: “Why is this so confusing?” I felt the same—until I changed how I thought about it. VIM isn’t a typical text editor. It’s closer to cloud architecture than a traditional ...

If you're preparing for a Linux Administrator interview, here's a question you'll likely hear: "How do you patch Linux servers without internet access?" This is one of the most common interview questions, and for good reason – it's a real-world scena...

Have you ever encountered a "Permission denied" error while trying to access a file on Linux? Or wondered what those cryptic rwxr-xr-- characters mean when you run ls -l? Understanding Linux file permissions is fundamental to working with any Unix-like operating system, whether you're a developer, system administrator, or just getting started with Linux.
In this comprehensive visual guide, we'll demystify Linux file permissions, explore how they work, and learn how to manage them effectively. By the end, you'll confidently navigate file ownership, permissions, and security on any Linux system.
File permissions in Linux are a security mechanism that controls who can read, write, or execute files and directories. Every file and directory has an associated set of permissions that determine three levels of access:
Owner (User) - The user who owns the file
Group - Users who are members of the file's group
Others - Everyone else on the system
Read (r) - View the file contents or list directory contents
Write (w) - Modify the file or directory contents
Execute (x) - Run the file as a program or access the directory
This combination of three permission types across three user categories creates a powerful and flexible security model.
Let's start by looking at how to view permissions. The ls -l command displays detailed information about files, including their permissions:
bash
$ ls -l
total 24
-rw-r--r-- 1 alice developers 1024 Dec 15 10:30 document.txt
-rwxr-xr-x 1 alice developers 2048 Dec 15 10:31 script.sh
drwxr-xr-x 2 alice developers 4096 Dec 15 10:32 my_directory
-rw-rw---- 1 alice developers 512 Dec 15 10:33 private.txt
Let's break down what each part means:
-rw-r--r-- 1 alice developers 1024 Dec 15 10:30 document.txt
│└┬┘└┬┘└┬┘ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ └─ Filename
│ │ │ │ │ │ │ │ └─ Modification time
│ │ │ │ │ │ │ └─ File size (bytes)
│ │ │ │ │ │ └─ Group name
│ │ │ │ │ └─ Owner name
│ │ │ │ └─ Number of hard links
│ │ │ └─ Others permissions (read, no write, no execute)
│ │ └─ Group permissions (read, no write, no execute)
│ └─ Owner permissions (read, write, no execute)
└─ File type (- = regular file, d = directory, l = symbolic link)
For Files:
View the file contents
Copy the file
Examples: cat, less, grep, cp
For Directories:
List the directory contents
See filenames inside the directory
Example: ls directory_name
Important Note: Read permission on a directory doesn't grant access to file contents, only to see the names of files in the directory.
For Files:
Modify file contents
Delete the file (if directory also has write permission)
Rename the file (if directory also has write permission)
Examples: nano, vim, echo, rm
For Directories:
Create new files in the directory
Delete files from the directory
Rename files in the directory
Create subdirectories
Examples: touch, mkdir, rm, mv
Important Note: Write permission on a directory allows you to delete files even if you don't have write permission on the files themselves!
For Files:
Run the file as a program or script
Examples: ./script.sh, python program.py
For Directories:
Access (enter) the directory
Access files within the directory if you know their names
Make it the current directory with cd
Example: cd directory_name
Critical Note: Without execute permission on a directory, you cannot access ANY files in that directory, even if you have read permission on the directory!
The user who owns the file. Usually the person who created it, but ownership can be transferred.
Example: Alice creates a file, so Alice is the owner.
A collection of users who share access to files. Every file belongs to one group.
Example: Alice and Bob are both in the "developers" group, so files owned by this group are accessible to both.
Everyone else on the system who is neither the owner nor in the group.
Example: Any user on the system who isn't Alice and isn't in the "developers" group.
Linux represents permissions in two different notations: symbolic (letters) and octal (numbers).
Uses letters to represent permissions:
r = read
w = write
x = execute
- = no permission
Format: rwxrwxrwx
First three characters = owner permissions
Second three characters = group permissions
Third three characters = others permissions
Examples:
rwxr-xr-x Owner: read, write, execute | Group: read, execute | Others: read, execute
rw-r--r-- Owner: read, write | Group: read | Others: read
rwx------ Owner: read, write, execute | Group: none | Others: none
r-------- Owner: read only | Group: none | Others: none
Uses numbers 0-7 to represent permissions. Each permission has a numeric value:
r (read) = 4
w (write) = 2
x (execute) = 1
Add these values together to get the permission number for each category.
Common Permission Values:
| Octal | Binary | Symbolic | Meaning |
| 0 | 000 | --- | No permissions |
| 1 | 001 | --x | Execute only |
| 2 | 010 | -w- | Write only |
| 3 | 011 | -wx | Write and execute |
| 4 | 100 | r-- | Read only |
| 5 | 101 | r-x | Read and execute |
| 6 | 110 | rw- | Read and write |
| 7 | 111 | rwx | Read, write, and execute |
Example Conversions:
rwxr-xr-x = 755
- Owner: rwx = 4+2+1 = 7
- Group: r-x = 4+0+1 = 5
- Others: r-x = 4+0+1 = 5
rw-r--r-- = 644
- Owner: rw- = 4+2+0 = 6
- Group: r-- = 4+0+0 = 4
- Others: r-- = 4+0+0 = 4
rwx------ = 700
- Owner: rwx = 4+2+1 = 7
- Group: --- = 0+0+0 = 0
- Others: --- = 0+0+0 = 0
Beyond the basic read, write, and execute permissions, Linux has three special permission bits:
When set on an executable file, the program runs with the permissions of the file's owner, not the user who executed it.
On Files: Program runs with the group permissions of the file's group.
On Directories: New files created in the directory inherit the directory's group, not the creator's default group.
When set on a directory, only the file owner, directory owner, or root can delete or rename files in that directory, even if others have write permission.
Understanding Linux file permissions is crucial for anyone working with Linux systems. While the concept might seem complex at first, the logic is straightforward:
Three permission types: Read (r), Write (w), Execute (x)
Three user categories: Owner (u), Group (g), Others (o)
Two notations: Symbolic (rwx) and Octal (755)
Three commands: chmod (change permissions), chown (change owner), chgrp (change group)
Mastering file permissions allows you to:
Secure sensitive data
Set up collaborative workspaces
Troubleshoot access issues
Configure servers correctly
Follow security best practices
Remember the principle of least privilege: start with restrictive permissions and open them up only as needed. When in doubt, use 644 for files and 755 for directories—these are safe defaults that work for most scenarios.
As you continue your Linux journey, file permissions will become second nature. Practice with the examples in this guide, experiment in a safe environment, and don't be afraid to check permissions frequently with ls -l. Happy securing!
man chmod: Detailed manual page (man chmod)
man chown: Ownership manual (man chown)
POSIX Permissions: Standards documentation
Advanced Topics: Access Control Lists (ACLs), SELinux contexts
Practice: Set up a local Linux VM and experiment safely
What permission challenges have you faced? Share your experiences in the comments below!
Tags: #Linux #FilePermissions #SystemAdministration #Security #DevOps #CommandLine #Tutorial