File Permissions & Ownership
DevOps engineer sharing daily learnings on Linux, Docker, Kubernetes, CI/CD, and Cloud.
Linux is a multi-user operating system, so it needs a strong permission system to control who can access what.
File permissions and ownership define security, access control, and system stability.
In this blog, we will learn:
How Linux permissions work
What
rwxmeansHow ownership is managed
Common commands with examples
Understanding File Permissions
Run:
ls -l
Example output:
-rwxr-xr-- 1 user group 1234 file.sh
Permission Breakdown :
-rwxr-xr--
β β β β
β β β ββ Others
β β βββββ Group
β βββββββββ Owner
βββββββββββ File type
Permission Types (rwx)
| Symbol | Meaning | Value |
| r | Read | 4 |
| w | Write | 2 |
| x | Execute | 1 |
Permission Categories
| Category | Description |
| Owner | File creator |
| Group | Group members |
| Others | Everyone else |
Numeric Permissions (chmod)
Numeric permissions use octal values.
Example :
chmod 755 script.sh
Explanation:
Owner: 7 (rwx)
Group: 5 (r-x)
Others: 5 (r-x)
Symbolic Permissions
chmod u+x file.sh
chmod g-w file.sh
chmod o+r file.sh
Where:
u= userg= groupo= othersa= all
Ownership in Linux
In Linux, every file and directory has an owner. Ownership controls who can access, modify, or execute a file.
π Owner
- Usually the user who created the file
π Group
- Used to share files among users
Types of Ownership
Each file has two ownership levels:
1οΈβ£ User (Owner)
The user who created the file
Has the most control over the file
Example:
-rw-r--r-- 1 apurv devops file.txt
Here:
- apurv β Owner
2οΈβ£ Group
A group of users who share access
Useful for team collaboration
Example:
-rw-r--r-- 1 apurv devops file.txt
Here:
- devops β Group
Why Ownership Matters
Ownership decides:
Who can read the file
Who can modify it
Who can execute it
Without correct ownership:
You may see Permission denied
Applications may fail
Scripts may not run
Checking Ownership
Use:
ls -l
Output:
-rwxr-xr-- 1 user group script.sh
Changing Ownership
Change owner
chown user file.txt
Change owner and group
chown user:group file.txt
Change only group
chgrp group file.txt
Ownership vs Permissions (Simple Difference)
| Ownership | Permissions |
| Who owns the file | What actions are allowed |
| User & Group | Read, Write, Execute |
Real-Life Example
Imagine a shared project folder:
Owner β Project lead
Group β Team members
Others β No access
This prevents accidental changes and improves security.
π Conclusion
File permissions and ownership are fundamental to Linux security.
Understanding them helps prevent:
Unauthorized access
Accidental system damage
Security breaches