Linux File Permissions — Understanding Read, Write, and Execute¶
Linux file permissions are one of the most important security features of the operating system. They determine who can read, modify, or execute files and directories. Every Linux administrator, DevOps engineer, Cloud Architect, and Security professional must understand permissions to secure systems, troubleshoot access issues, and manage production environments.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand Linux permissions
- Read permission strings
- Understand User, Group, and Others
- Learn Read, Write, and Execute permissions
- Understand numeric (octal) permissions
- Verify permissions
- Understand directory permissions
- Troubleshoot permission issues
Prerequisites¶
Complete:
- Module 1
- Module 2
- Module 3
- Module 4 Lessons 1–3
Why Learn Permissions?¶
Imagine you're deploying a web application.
Suddenly users receive:
Questions:
- Does the application have permission to read the file?
- Can the web server execute the script?
- Is the configuration file writable?
- Which user owns the file?
Almost every Linux administrator encounters permission-related issues daily.
Viewing Permissions¶
Use:
Example:
The first part represents the permissions.
Let's break it down.
Permission Structure¶
-rwxr-xr--
│││ │││ │││
│││ │││ │└── Others
│││ │││ └── Others
│││ ││└──── Others
│││ └────── Group
││└──────── Group
│└───────── Group
└────────── User
Or visually:
File Type¶
The first character indicates the file type.
| Symbol | Meaning |
|---|---|
- | Regular File |
d | Directory |
l | Symbolic Link |
c | Character Device |
b | Block Device |
p | Named Pipe |
s | Socket |
The Three Permission Sets¶
Every file has permissions for:
- User (Owner)
- Group
- Others
Example:
Read Permission ®¶
Symbol:
Value:
Allows:
- View file contents
- Open files
- Copy files
Example:
For directories:
Allows:
- List directory contents
Example:
Write Permission (w)¶
Symbol:
Value:
Allows:
- Modify files
- Save changes
- Delete contents
Example:
For directories:
Allows:
- Create files
- Delete files
- Rename files
Execute Permission (x)¶
Symbol:
Value:
Allows:
Execute programs.
Example:
Without execute permission:
For directories:
Allows entering the directory.
Without execute permission:
Permission Values¶
| Permission | Value |
|---|---|
| Read | 4 |
| Write | 2 |
| Execute | 1 |
Combining Permissions¶
| Symbol | Value |
|---|---|
--- | 0 |
--x | 1 |
-w- | 2 |
-wx | 3 |
r-- | 4 |
r-x | 5 |
rw- | 6 |
rwx | 7 |
Understanding 755¶
Means:
Equivalent:
Understanding 644¶
Means:
Equivalent:
Understanding 700¶
Equivalent:
Only the owner has access.
Common Permission Modes¶
| Numeric | Symbolic | Common Use |
|---|---|---|
| 777 | rwxrwxrwx | Testing only (avoid in production) |
| 755 | rwxr-xr-x | Scripts and directories |
| 750 | rwxr-x--- | Team collaboration |
| 700 | rwx------ | Private files |
| 644 | rw-r--r-- | Configuration and text files |
| 640 | rw-r----- | Sensitive configuration |
| 600 | rw------- | SSH keys, secrets |
Directory Permissions¶
Directory permissions behave differently.
Suppose:
Read (r):
- List directory contents
Write (w):
- Create
- Delete
- Rename files
Execute (x):
- Enter the directory
- Access files inside
Viewing Permissions¶
Display numeric mode.
Example:
Permission Examples¶
Executable script.
Configuration file.
SSH private key.
Directory.
Real Production Examples¶
Application script.
NGINX configuration.
SSH private key.
Kubernetes kubeconfig.
Production Perspective¶
Permissions are critical for:
- Linux servers
- Web servers
- Kubernetes
- Docker
- SSH
- Cloud infrastructure
- Databases
- CI/CD pipelines
Incorrect permissions can lead to:
- Application failures
- Security vulnerabilities
- Unauthorized access
- Production outages
Hands-on Lab¶
Task 1¶
Create a file.
Task 2¶
Display permissions.
Task 3¶
Create a directory.
Task 4¶
View directory permissions.
Task 5¶
Inspect file metadata.
Task 6¶
Create a shell script.
Display permissions.
Task 7¶
Try executing the script.
Observe the permission error (until execute permission is granted in the next lesson).
Task 8¶
Compare permissions of:
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
ls -l | View permissions | Daily administration |
ls -ld | View directory permissions | Troubleshooting |
stat | Detailed file metadata | Auditing |
file | Identify file type | Verification |
Production Troubleshooting Scenario¶
Scenario
A deployment script fails with:
Investigation:
The script lacks execute permission.
This issue is commonly encountered during deployments, CI/CD runs, and script migrations.
Best Practices¶
- Follow the Principle of Least Privilege.
- Avoid
777permissions in production. - Use
600for private keys and secrets. - Use
644for configuration files. - Regularly audit file permissions.
- Understand directory permissions before changing them.
Common Mistakes¶
❌ Granting 777 permissions to solve every issue.
✅ This creates serious security risks.
❌ Forgetting that directory execute permission controls access.
✅ Without x, users cannot enter the directory even if they have read permission.
❌ Confusing file permissions with ownership.
✅ Permissions and ownership work together but are managed separately.
Interview Questions¶
Beginner¶
- What are Linux file permissions?
- What do
r,w, andxrepresent? - What are the three permission classes?
- What does
755mean?
Intermediate¶
- Explain the difference between file and directory execute permissions.
- Why is
644commonly used for configuration files? - Why should private keys use
600? - What information does
statprovide?
Architect Level¶
- How would you secure sensitive configuration files on a production server?
- Why is the Principle of Least Privilege important?
- How would you audit permissions across thousands of servers?
Summary¶
In this lesson, you learned:
- Linux permission structure
- User, Group, and Others
- Read, Write, and Execute permissions
- Numeric permission values
- Directory permissions
- Permission inspection
- Production security considerations
Linux permissions are one of the core security mechanisms of the operating system. A strong understanding of permissions helps you build secure systems, troubleshoot access problems, and manage production environments confidently.
Key Takeaways¶
- Every file has permissions for User, Group, and Others.
- Read = 4, Write = 2, Execute = 1.
755is common for executable scripts and directories.644is common for regular files.600is recommended for sensitive files such as SSH private keys.- Avoid using
777in production unless absolutely necessary.
What's Next?¶
Linux File Ownership — Understanding Users, Groups, and File Ownership
In the next lesson, you'll learn:
- File owners and groups
- Viewing ownership with
ls,id, andstat - Changing ownership with
chownandchgrp - Recursive ownership changes
- Production ownership troubleshooting