Linux File Permissions Explained: A Complete Beginner's Guide to chmod, chown, and Secure Access
📚 Linux Learning Path
- ✅ Introduction to Linux
- ✅ Understanding the Linux Terminal
- ✅ Essential Linux Commands
- ✅ Linux File System Explained
- ➡ Linux File Permissions Explained (Current)
- ○ Linux Users & Groups
- ○ Process Management
- ○ Package Management
- ○ Shell Scripting
- ○ SSH
“A colleague once asked why he couldn't edit a configuration file even though he was logged into the server. The file was right there, but every attempt ended with 'Permission denied.' The issue wasn't the file—it was the permissions. Understanding how Linux controls access is one of the most important skills you'll develop.”
If you've ever seen a Permission denied message in Linux, don't worry—it's something every Linux user encounters sooner or later.
Unlike some operating systems that hide security details from users, Linux makes permissions clear and consistent. Every file and directory has rules that determine who can read it, who can modify it, and who can execute it.
Once you understand these rules, you'll not only become more confident using Linux, but you'll also build habits that are essential for system administration, DevOps, and cybersecurity.
In this guide, we'll break everything down step by step.
Why Does Linux Use File Permissions?
Imagine you're working in an office.
- Not everyone should have access to payroll records.
- Not everyone should be able to modify company policies.
- Some employees can only view documents.
- Others can edit them.
- A few administrators can access everything.
Linux follows the same principle.
Permissions protect files from accidental changes and unauthorized access. Without them, any user could delete important files or modify critical system settings.
Every File Has Three Permission Groups
When you create a file in Linux, the operating system automatically assigns permissions to three different groups:
- Owner (User) – The person who owns the file.
- Group – Users who belong to the assigned group.
- Others – Everyone else on the system.
Think of it this way:
Project Report
Owner → Alice
Group → Developers
Others → Everyone else
Each group can have different levels of access.
The Three Basic Permissions
Linux permissions are built around three simple actions.
Read (r)
Read permission allows a user to open and view a file.
For directories, it allows users to list the contents.
Write (w)
Write permission allows users to modify a file.
For directories, it allows users to create, rename, or delete files inside that directory.
Execute (x)
Execute permission allows Linux to run a file as a program or script.
For directories, it allows users to enter the directory using the cd command.
Viewing File Permissions
The easiest way to see permissions is with:
ls -l
Example output:
-rw-r--r-- 1 ashish developers 2048 Jul 17 report.txt
At first glance, this may look confusing. Let's break it down.
Understanding the Permission String
Take the first section:
-rw-r--r--
Each character has meaning.
First Character
-
This tells us the object type:
-= Filed= Directoryl= Symbolic Link
Owner Permissions
rw-
The owner can:
- ✔ Read
- ✔ Write
- ✘ Execute
Group Permissions
r--
Members of the assigned group can only read the file.
Others
r--
Everyone else can read it, but cannot modify it.
Understanding Permission Numbers
Linux also represents permissions using numbers.
| Permission | Value |
|---|---|
| Read | 4 |
| Write | 2 |
| Execute | 1 |
Add the values together.
| Permission | Number |
|---|---|
rwx | 7 |
rw- | 6 |
r-x | 5 |
r-- | 4 |
--- | 0 |
This numbering system is used with the chmod command.
Using chmod
chmod stands for change mode.
It changes file permissions.
Example:
chmod 644 report.txt
What does 644 mean?
- Owner: 6 = Read + Write
- Group: 4 = Read
- Others: 4 = Read
Another example:
chmod 755 script.sh
- Owner: Read + Write + Execute
- Group: Read + Execute
- Others: Read + Execute
This is a common permission setting for executable scripts.
Symbolic Mode
Instead of numbers, you can also use letters.
Add execute permission:
chmod +x script.sh
Remove write permission:
chmod -w report.txt
Give the owner execute permission:
chmod u+x script.sh
Allow the group to write:
chmod g+w shared.txt
Remove execute permission from others:
chmod o-x program.sh
Many administrators use symbolic mode because it's easier to read and understand.
Understanding chown
Permissions determine what users can do.
Ownership determines who controls the file.
To change the owner:
sudo chown john report.txt
Change owner and group together:
sudo chown john:developers report.txt
Ownership changes are common when moving files between users or deploying applications.
Understanding chgrp
Need to change only the group?
sudo chgrp developers report.txt
This is useful when several users need shared access to project files.
File Permissions vs Directory Permissions
Directories behave slightly differently.
For a directory:
- Read: Allows viewing file names.
- Write: Allows creating, deleting, or renaming files.
- Execute: Allows entering the directory.
This explains why you might see a folder but still be unable to open it.
Common Permission Settings
| Numeric | Meaning | Typical Use |
|---|---|---|
| 644 | Owner can edit, everyone else can read | Text files |
| 600 | Owner only | Private keys, passwords |
| 755 | Owner full access, others can read and execute | Scripts and applications |
| 700 | Owner only, full control | Private directories |
| 777 | Everyone can do everything | Generally avoid |
Why 777 Is Usually a Bad Idea
Beginners often search for quick fixes and find advice like:
chmod 777 file.txt
Although it may solve a permission problem, it also allows anyone on the system to read, modify, and execute the file.
On multi-user systems, this can create serious security risks.
It's usually better to understand why access is denied than to grant unrestricted permissions.
Practice Lab
🧪 Hands-on practice
Create a practice directory.
mkdir permissions-lab
cd permissions-lab
Create a file.
touch notes.txt
Check permissions.
ls -l
Change permissions.
chmod 600 notes.txt
Check again.
ls -l
Try changing them to 644 and then 755 to see how the permission string changes.
Common Beginner Mistakes
Confusing Ownership with Permissions
A file may have correct permissions but still belong to the wrong owner. Always check both.
Using 777 Everywhere
Avoid making every file writable just because it's convenient. Choose the minimum permissions required.
Forgetting Directory Permissions
Sometimes the file permissions are correct, but the parent directory blocks access. Check the directory as well.
Best Practices
- Follow the principle of least privilege.
- Avoid running commands as the root user unless necessary.
- Use
chmodthoughtfully. - Change ownership only when appropriate.
- Review permissions regularly on important systems.
Interview Questions
What is the difference between chmod and chown?
chmod changes permissions. chown changes ownership.
What does permission 755 represent?
Owner has read, write, and execute permissions. Group and others have read and execute permissions.
Why is 777 discouraged?
Because it grants unrestricted access to all users, increasing security risks.
Key Takeaways
You learned:
- Why Linux uses permissions.
- The difference between owners, groups, and others.
- How read, write, and execute permissions work.
- How to use
chmod. - How to use
chown. - Why secure permission management matters.
These concepts form the foundation of Linux security.
Frequently Asked Questions
Usually because your user account doesn't have the required permission or ownership.
A common choice is 755, allowing the owner to edit while others can execute the script.
Yes. Simply run chmod again with the desired permission value.
The root user has broad administrative privileges and can generally bypass standard permission restrictions, though some security mechanisms may impose additional controls.
What's Next?
Now that you understand how Linux protects files and directories, it's time to learn who those permissions apply to.
In the next guide, we'll explore Linux Users and Groups, explain how accounts are managed, how groups simplify administration, and how user management contributes to a secure Linux system.
