🔐 Understanding Linux File Permissions — A DevOps Must-Know Skill.


If you're on the DevOps journey (like I am!), learning Linux file permissions is not just helpful — it’s absolutely essential. Whether you're configuring a Jenkins pipeline, managing an EC2 server, or deploying a script via Docker, file permission errors can make or break your automation.
So in this post, I’ll walk you through:
✅ What Linux file permissions are
✅ How they work behind the scenes
✅ Commands you can use (chmod
, chown
, ls -l
)
✅ Real-world DevOps relevance
✅ A cheat sheet to remember them forever
🔧 What Are Linux File Permissions?
In Linux, every file and directory has a set of permissions that determine who can read, write, or execute them.
There are three types of permissions:
Symbol | Permission | Description |
r | Read | View file contents or list directory |
w | Write | Modify file or directory |
x | Execute | Run file as a script or binary |
These apply to three roles:
Role | Description |
u (user) | The file owner |
g (group) | The group the file belongs to |
o (others) | Everyone else |
📂 Example: Breaking Down File Permission Format
Let’s look at an example:
-rwxr-xr-- 1 abhijit dev file.sh
Here’s how to read it:
Symbol Set | Meaning |
- | It's a file (not a directory) |
rwx | User (abhijit) can read, write, execute |
r-x | Group (dev) can read, execute |
r-- | Others can only read |
So, the owner has full control, the group can execute, and others can only view it.
🛠️ Key Linux Permission Commands
Here are the must-know commands for working with file permissions:
1. ls -l
List files with detailed permission info:
ls -l
2. chmod
(Change Mode)
Change permission settings.
Add execute permission to a script:
chmod +x script.sh
Set exact permissions using numeric notation:
chmod 755 script.sh # Equivalent to: rwxr-xr-x
Number | Permission | Explanation |
7 | rwx | Read, write, execute |
6 | rw- | Read, write |
5 | r-x | Read, execute |
4 | r-- | Read only |
So 755
means:
User: 7 (rwx)
Group: 5 (r-x)
Others: 5 (r-x)
3. chown
(Change Owner)
Change the ownership of a file:
chown abhijit:dev file.sh
4. chgrp
(Change Group)
Change just the group:
chgrp dev file.sh
💡 Real-World DevOps Relevance
Here’s where this becomes super valuable for DevOps engineers:
🔸 Jenkins won't execute a shell script unless it has execute permission (+x
)
🔸 Docker containers often throw "Permission Denied" errors when running volumes or scripts
🔸 EC2 instances may block SSH key access if .ssh
folder has wrong permissions
🔸 Config files in /etc/
must be protected from accidental writes
When a pipeline fails or a deployment breaks, the first thing to check is permissions.
🔁 Troubleshooting Tips
🔸 If you get:
Permission denied
Always check:
ls -l filename
🔸 If Jenkins can’t run a script:
chmod +x script.sh
🔸 If Docker can’t access a volume:
ls -ld /your/volume
chmod 755 /your/volume
🧠 File Permission Cheat Sheet
Symbol | Octal | Description |
r-- | 4 | Read |
rw- | 6 | Read + Write |
rwx | 7 | Read + Write + Exec |
--- | 0 | No permissions |
Permission combo:
chmod 754 file # Means: User = rwx, Group = r-x, Others = r--
🧪 Practice Exercise
Here’s a quick challenge to test yourself:
- Create a file:
touch test.sh
- Make it executable:
chmod +x test.sh
- Give full access to user, read/execute to group, no access to others:
chmod 750 test.sh
- Change ownership:
sudo chown abhijit:dev test.sh
Check your work with:
ls -l test.sh
🚀 Final Thoughts
Learning file permissions may seem boring at first…
But it’s a skill that will save you hours of debugging and help you become a DevOps pro.
I used to ignore permission errors. Now, I know exactly what they mean — and how to fix them with confidence 💪
📣 What’s Next?
Up next in my Linux learning series:
🧠 File ownership, symbolic vs absolute paths, and the power of sudo
.
If you’re on the DevOps path, follow along — or drop a comment if you want help understanding any Linux concept!
#DevOps #Linux #FilePermissions #chmod #chown #CI_CD #Jenkins #AWS #Docker #SysadminSkills #BeginnersWelcome
Subscribe to my newsletter
Read articles from Abhijit Sagare directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
