Welcome to Day 3 of the 30 Days of Linux Challenge. Today, we’re going to explore something that affects every Linux user — whether you’re creating files, writing scripts, managing servers, or working in a shared system.
We’re talking about file permissions.
File permissions define who can read, write, or execute a file — and controlling this is essential for both security and system integrity.
📚 Table of Contents
- Why Permissions Matter
- Reading File Permissions
- Understanding the Roles
- Symbolic vs Numeric Permissions
- Changing Permissions with
chmod
- Changing Ownership:
chown
andchgrp
- Try It Yourself
- Why This Matters
Why Permissions Matter
In a multi-user environment — even if you're the only user on your system — setting file permissions correctly ensures that files:
- Aren’t accidentally modified by the wrong users
- Can’t be executed if they shouldn't be
- Are protected against unauthorized access
Whether you're managing a script, hosting a web app, or just keeping your system clean, permissions are your first line of control.
Reading File Permissions
Let’s look at a typical output from the ls -l
command:
-rwxr-xr--
- rwx r-x r-- | | | | | | | +-- Others (everyone else) | | +------ Group (users in the same group) | +---------- Owner (you, typically) +------------- File type (- = regular file, d = directory)
What do the letters mean?
r = read permission
w = write (edit/delete)
x = execute (run a file/script)
So in the example above:
The owner can read, write, and execute the file.
The group can read and execute it.
Others can only read it.
Understanding the Roles
Linux recognizes three main types of users for each file:
Role :: Description
Owner :: The person who created or owns the file
Group :: A user group associated with the file
Others :: Anyone else with access to the system
Each role can have different levels of access.
Symbolic vs Numeric Permissions
You can express permissions in symbolic form (rwxr-xr--) or in numeric (octal) form (754, 644, etc.).
-rwxr-xr-- → user: rwx, group: r-x, others: r--
Numeric Form:
Each permission has a value:
r = 4
w = 2
x = 1
Add them up:
rwx = 4 + 2 + 1 = 7
r-x = 4 + 0 + 1 = 5
r-- = 4 + 0 + 0 = 4
So, rwxr-xr-- becomes 754
Changing Permissions with chmod
The chmod command is used to change file permissions.
This means:
Owner: read, write, execute
Group: read, execute
Others: read, execute
You can also use symbolic format:
chmod u+x my_script.sh # Add execute permission to the owner
chmod g-w my_script.sh # Remove write permission from the group
Changing Ownership: chown and chgrp
Sometimes you’ll need to change the owner or group associated with a file.
chown newuser filename
chgrp newgroup filename
Try It Yourself
Here’s a quick terminal activity:
touch demo.txt # Create a new file
ls -l demo.txt # View default permissions
chmod 744 demo.txt # Set specific permissions
ls -l demo.txt # Confirm the change
You should now see:
-rwxr--r-- 1 user group 0 Apr 8 12:00 demo.txt
Why This Matters
Setting file permissions correctly:
Prevents security breaches
Ensures proper file access in shared systems
Avoids accidental data loss or execution
Whether you’re deploying a web app, writing bash scripts, or working with automation — permission management is a must-have skill.