← Back to Home
πŸ”’

Linux Permissions

Read, understand, and change file permissions and ownership β€” a skill DevOps engineers use every day.

⏱12 min readπŸ“šDevOps Fundamentals

One of the biggest reasons Linux is trusted to run the world’s servers is its powerful permission system. Permissions decide who can read, modify, and execute each file. Without them, any user could change or delete critical system files.


🎯 Learning Objectives

By the end of this lesson you will:


Reading Permissions

Run ls -l and you’ll see a permission string at the start of each line:

bash β€” 80Γ—24
student@devops:~$ls -l notes.txt

That string breaks down into three groups of three:

text
-  rw-  r--  r--
β”‚   β”‚    β”‚    └── Others : read
β”‚   β”‚    └─────── Group  : read
β”‚   └──────────── Owner  : read + write
└──────────────── file type ( - = file, d = directory )

r = read    w = write    x = execute

Changing Permissions with chmod

Make a script executable:

bash
chmod +x deploy.sh   # add execute permission
chmod -x deploy.sh   # remove execute permission

After chmod +x, the permission string gains an x: -rwxr-xr-x.

Numeric (octal) permissions

Linux also lets you set permissions with numbers β€” read = 4, write = 2, execute = 1, added together per group:

Number Permission Meaning
7 rwx read + write + execute
6 rw- read + write
5 r-x read + execute
4 r-- read only

The most common command you’ll type:

bash
chmod 755 deploy.sh   # owner: rwx, group: r-x, others: r-x

Changing Ownership with chown

The first two names in ls -l are the owner and the group. To change ownership:

bash
sudo chown ubuntu deploy.sh   # make 'ubuntu' the owner

Real DevOps Example

A deployment script that isn’t executable fails with a clear error β€” and the fix is one command:

bash β€” 80Γ—24
student@devops:~$./deploy.sh

This is something DevOps engineers do regularly.


πŸ§ͺ Hands-on Lab

πŸ“

Make a Script Executable

  1. Create a file named test.sh
  2. Check its permissions with ls -l
  3. Add execute permission with chmod +x
  4. Check the permissions again β€” notice the x appear

⚠ Never chmod 777 everything

chmod 777 gives everyone full read/write/execute access. It’s a common beginner shortcut and a serious security risk. Follow the principle of least privilege β€” grant only the access actually needed.


🧠 Knowledge Check

Knowledge Check

Which command changes a file's permissions?

Knowledge Check

What access does chmod 755 grant to the file's owner?


πŸ’Ό Interview Preparation

Interview Q&A

Explain what chmod 644 and chmod 755 mean and when you'd use each.


Summary

You now understand one of Linux’s most important security features. Every DevOps engineer works with chmod, chown, and permission strings almost daily.

Up Next

Bash and Shell Scripting

You've mastered this lesson. Continue your journey to becoming a DevOps Engineer.

Start Next Lesson→