Skip to main content

Command Palette

Search for a command to run...

File Permissions & Ownership

Published
β€’3 min read
A

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 rwx means

  • How 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)

SymbolMeaningValue
rRead4
wWrite2
xExecute1

Permission Categories

CategoryDescription
OwnerFile creator
GroupGroup members
OthersEveryone 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 = user

  • g = group

  • o = others

  • a = 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)

OwnershipPermissions
Who owns the fileWhat actions are allowed
User & GroupRead, 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

Linux Essentials

Part 5 of 5

Linux Essentials is a practical series covering core Linux concepts from a DevOps perspectiveβ€”architecture, filesystem, permissions, processes, networking, and servicesβ€”focused on real-world usage in production and cloud environments.

Start from the beginning

Linux Architecture

If you are new to Linux, you might wonder: πŸ‘‰ How does Linux actually work inside?πŸ‘‰ What happens when I type a command in the terminal? Linux architecture answers these questions. It explains how Linux is structured and how different parts work toge...