Linux Phase 3: Permissions & Ownership

  • 🎯 Target Audience: Beginners in DevOps & DevSecOps

  • 🧠 Key Concepts: chmod, chown, sudo, file permissions, principle of least privilege

  • ⏱️ Estimated Read Time: 7-9 minutes

  • πŸ’‘ Outcome: Understand how to manage permissions & ownership for secure automation and system control

  • πŸ› οΈ Series: Part 3 of the β€œLinux for DevOps Beginners” series

  • πŸ”’ Real-World Focus: Enforce security, automate with confidence, and avoid permission hell in CI/CD pipelines


πŸ§‘β€πŸ’» Why Permissions Really Matter

In the world of DevOps and DevSecOps, you’re not just pushing code, you’re managing infrastructure, securing systems, and automating everything from deployments to monitoring.

That means you must know what a chmod 755 or a sudo chown root:nginx actually does. Without this knowledge, you’re flying blind, or worse, breaking things in production.

This guide will break down Linux permissions and ownership into simple, snackable chunks, with real-life use cases to show how this knowledge powers automation, security, and control.


πŸ” Linux Permissions & Ownership 101

πŸ“‚ The Linux File Permission Model

Every file and directory in Linux has three types of access for three types of users:

Who?What?
User (u)The owner of the file
Group (g)Users who are part of the file’s group
Others (o)Everyone else

And they can perform three actions:

ActionSymbolMeaning
ReadrView contents
WritewModify contents
ExecutexRun the file (scripts/programs)

🧠 Try This:

ls -l

This will list files like so:

-rwxr-xr-- 1 user devops_team 2048 Aug 7 12:00 deploy.sh

πŸ”Ž Read this as: User has read/write/execute (rwx), Group has read/execute (r-x), Others can only read (r--)


πŸ› οΈ chmod β€”> Change Permissions

The chmod command sets who can do what to a file.

Example: Give execute permission to a script

chmod +x deploy.sh

Example: Set exact permissions

chmod 755 deploy.sh
# rwxr-xr-x β†’ owner: all perms, group: read+exec, others: read+exec

Numeric breakdown:

NumberMeaning
7rwx
6rw-
5r-x
4r--

πŸ”’ chmod Numeric Permissions Reference

Each permission is assigned a number:

  • Read (r) = 4

  • Write (w) = 2

  • Execute (x) = 1

Add them up to get permission numbers:

UserGroupOtherschmod Valuerwx Representation
755755rwx r-x r-x
644644rw- r-- r--
700700rwx --- ---
600600rw- --- ---
777777rwx rwx rwx

Use this as your go-to cheat sheet when setting permissions manually.


πŸ§‘β€πŸ€β€πŸ§‘ chown β€”> Change File Ownership

The chown command changes the owner or group of a file.

Example: Change ownership to nginx user

sudo chown nginx:nginx /var/www/html/index.html

πŸ” Useful when deploying files through CI/CD where the app server needs ownership.


⚑ sudo β€”> Superuser Powers

The sudo command lets a user execute commands as root (admin).

Example: Installing a package

sudo apt update && sudo apt install nginx

πŸ”” Warning: Sudo gives you complete control over the system. Misuse can be catastrophic use it wisely and always double-check.


πŸ”‘ Principle of Least Privilege (PoLP)

One of the core DevSecOps security principles:

βœ… Only give the access that's absolutely needed, and nothing more.

Use chmod, chown, and sudo to enforce this:

ScenarioPermission Strategy
Script used in CI pipelinechmod +x, owned by pipeline user
Web server filechown www-data:www-data
Deployment tool configchmod 600 config.yaml (read/write owner only)

πŸ€– Real-Life DevOps Use Case

🎯 Scenario: You're setting up a deployment pipeline for a Node.js app on a Linux server.

πŸͺ„ Without permissions knowledge:

  • Scripts fail with "Permission denied"

  • Server can't read the app files

  • CI/CD breaks when trying to overwrite configs

βœ… With permissions mastery:

# Make your start script executable
chmod +x start.sh

# Ensure web user owns files
sudo chown -R nginx:nginx /var/www/myapp

# Secure environment config
chmod 600 .env

Boom πŸ’₯: now everything runs smoothly, securely, and automatically.


πŸ“š Recap

βœ… Linux file permissions control who can do what

βœ… Use chmod to adjust access rights

βœ… Use chown to set ownership

βœ… Use sudo wisely for admin tasks

βœ… Follow PoLP to build secure, reliable systems


If this helped clear the fog around Linux permissions, drop a comment below πŸ‘‡ Which command tripped you up the most at first: chmod, chown, or sudo?

πŸ‘‰ Share this with your fellow DevOps beginners

πŸ” Revisit Part 1 & Part 2 of the series

πŸ’Œ Subscribe to the newsletter to get the next phase: "Linux Phase 4 : Search, Info & Help" πŸš€


πŸ‘¨β€πŸ« About the Author

I'm Abdulrahman A. Muhamad, a DevOps engineer focused on practical security, automation, and reliability. Through blogs and tutorials, I help you master the tools and mindsets that power modern cloud infrastructure.

0
Subscribe to my newsletter

Read articles from Abdulrahman Ahmad directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abdulrahman Ahmad
Abdulrahman Ahmad

πŸš€ Code. Automate. Innovate. Hi, I’m Abdulrahman, a passionate DevOps Engineer and Software Developer on a mission to bridge the gap between code and production. With a love for automation, cloud-native solutions, and cutting-edge tech, I turn complex problems into seamless, scalable systems. πŸ’‘ What I Do: Build robust CI/CD pipelines that deliver software at the speed of thought. Architect cloud infrastructure that scales with a single command. Transform manual processes into automated workflows that just work. Break down silos and foster collaboration between teams. πŸ”§ Tech Stack I ❀️: Containers (Docker), Orchestration (Kubernetes), Infrastructure as Code (Terraform), CI/CD (Jenkins, GitLab), Cloud (AWS/GCP/Azure), and scripting like it’s my superpower. πŸ“ Why This Blog? This is where I share my journey, lessons learned, and the latest trends in DevOps and software engineering. Whether you're a seasoned pro or just starting out, join me as we explore the tools, tricks, and best practices that make the tech world tick. 🌟 Let’s Build the Future, One Pipeline at a Time. Connect with me, share your thoughts, and let’s automate the world together!