File Permissions Complete Guide with Examples
Introduction
Suppose that you own a house. You decide who can enter, who can stay, and who can make changes inside. Some people may only visit, while others may have full control. Computers work in a very similar way through file permissions.
File permissions determine who can read, modify, or execute files and folders. They are one of the most important security features in Linux, Unix, and even Windows systems. Proper file permissions help protect sensitive information, prevent accidental changes, and improve overall system security.

In this guide, you’ll learn what file permissions are, how they work, and how to manage them with practical examples.
What Are File Permissions?
File permissions are rules that define what actions users can perform on files and directories.
These permissions determine whether a user can:
- Read a file
- Edit or modify it
- Run it as a program
- Access a directory
Without permissions, anyone could delete or modify important system files, making the operating system unstable.
Why File Permissions Matter
File permissions help:
- Protect sensitive data
- Prevent unauthorized access
- Reduce accidental deletion
- Improve system security
- Manage multi-user environments
For example, in a company, employees should not be able to modify payroll files.
Example
Imagine a school library.
There are three groups of people:
- Librarian
- Teachers
- Students
The library contains different books and records.
Permissions work like this:
| Person | Permission |
| Librarian | Read, edit, remove books |
| Teacher | Read and borrow books |
| Student | Read books only |
This is exactly how file permissions work.
Different users receive different access levels.
Three Basic Permissions
Linux uses three basic permissions.
1. Read (r)
Allows viewing the contents of a file.
Example:
You can open a PDF or text file but cannot edit it.
Permission:
r
2. Write (w)
Allows modifying the file.
You can:
- Edit
- Rename
- Delete
- Save changes
Permission:
w
3. Execute (x)
Allows running the file as a program or script.
Example:
backup.sh
Without execute permission:
Permission denied
After adding execute permission:
./backup.sh
The script runs successfully.
File Permission Groups
Linux divides permissions into three categories.
Owner (u)
The person who created the file.
Example:
saqib
Group (g)
Users belonging to the same group.
Example:
developers
Others (o)
Everyone else on the system.
Example:
Guests or normal users.
Permission Structure
Run:
ls -l
Example output:
-rwxr-xr–
Let’s break it down.
–
rwx
r-x
r–
Meaning:
File Type
Owner:
Read
Write
Execute
Group:
Read
Execute
Others:
Read
Understanding the Symbols
| Symbol | Meaning |
| r | Read |
| w | Write |
| x | Execute |
| – | Permission not granted |
Numeric Permission Values
Linux also uses numbers.
| Permission | Value |
| Read | 4 |
| Write | 2 |
| Execute | 1 |
Add the values.
Example:
Read + Write + Execute
4 + 2 + 1 = 7
Common Permission Numbers
| Number | Permission |
| 777 | Everyone has full access |
| 755 | Owner full, others read & execute |
| 700 | Only owner has access |
| 644 | Owner can edit, others can read |
| 600 | Owner read & write only |
Example
Permission:
755
Means:
Owner
Read ✔
Write ✔
Execute ✔
Group
Read ✔
Write ✘
Execute ✔
Others
Read ✔
Write ✘
Execute ✔
Viewing Permissions
Command:
ls -l
Example:
-rw-r–r– notes.txt
Meaning:
Owner:
Read
Write
Group:
Read
Others:
Read
Changing Permissions
Linux uses the chmod command.
Symbolic Method
Give execute permission.
chmod +x script.sh
Remove write permission.
chmod -w file.txt
Add read permission.
chmod +r file.txt
Numeric Method
Example:
chmod 755 script.sh
Example:
chmod 644 notes.txt
Example:
chmod 700 secret.txt
Changing File Ownership
Use:
chown
Example:
sudo chown ali file.txt
Now the owner becomes:
ali
Changing Group Ownership
sudo chgrp developers project
Now the file belongs to:
developers
Directory Permissions
Directories also have permissions.
For directories:
Read:
Allows listing files.
Write:
Allows creating or deleting files.
Execute:
Allows entering the directory.
Example:
cd Documents
Without execute permission:
Permission denied
Secure Permission Practices
Recommended permissions:
| File Type | Permission |
| Website files | 644 |
| Directories | 755 |
| Private keys | 600 |
| Shell scripts | 755 |
| Configuration files | 640 or 600 |
Dangerous Permissions
Never use:
chmod 777
unless absolutely necessary.
Reason:
Everyone can:
- Read
- Edit
- Delete
- Execute
This creates serious security risks.
Example
Suppose you have:
salary.xlsx
You don’t want coworkers to edit it.
Set:
chmod 600 salary.xlsx
Now only you can read and modify the file.
Example
Imagine a company’s HR department.
The folder contains employee records.
Permissions:
- HR Manager: Read, Write, Execute
- HR Staff: Read and Write
- Other Employees: No Access
Linux permissions enforce this same level of controlled access, ensuring confidential information remains protected.
Best Practices
- Follow the principle of least privilege (give only the permissions needed).
- Avoid using 777 on production servers.
- Regularly audit file permissions.
- Keep sensitive files restricted with 600 or 640.
- Assign users to groups instead of giving permissions individually.
- Review permissions after software installations or migrations.
Advantages of File Permissions
- Protects sensitive information
- Prevents unauthorized modifications
- Supports secure multi-user systems
- Reduces accidental file deletion
- Enhances server security
- Simplifies access management
Disadvantages
- Incorrect settings may block legitimate users.
- Overly permissive access can create security vulnerabilities.
- Managing permissions on large systems requires planning and regular maintenance.
Conclusion
File permissions are a fundamental part of operating system security. By controlling who can read, modify, or execute files, they help protect data, support collaboration, and keep systems stable. Whether you’re managing a personal Linux computer, a web server, or an enterprise network, understanding file permissions is an essential skill. Learning to use commands like ls, chmod, chown, and chgrp will enable you to manage files securely and confidently.


