π― What Youβll Learn
In this episode, weβll break down:
-
What file permissions are π
-
How to read them π
-
How to change them using
chmod
π -
Real-world analogies that actually make sense π·ββοΈ
All based on RHCSA exam objectives.
π¦ Why Permissions Matter?
Imagine Linux as an apartment building:
-
Every file or folder is like a room.
-
Each user is a tenant.
-
Permissions control who can enter, modify, or even see what's inside the room.
Without the correct permissions, users may:
-
Get denied access
-
Accidentally modify system files π¬
-
Or worse β cause security issues π¨
π§Ύ Understanding the Permission Format
Run this command:
ls -l
Youβll see something like:
-rw-r--r--. 1 alice developers 1234 Jul 7 12:00 report.txt
Breakdown of -rw-r--r--
:
Position | Meaning |
---|---|
| File type ( |
| Owner's permission (read & write) |
| Groupβs permission (read-only) |
| Othersβ permission (read-only) |
π Permissions are always in this order:
User | Group | Others
π§ Real-World Analogy
Permission | Symbol | Meaning | Real-World |
---|---|---|---|
Read |
| View content | Can read a document |
Write |
| Modify content | Can edit a document |
Execute |
| Run file as program | Can open/run a program or enter a room |
For directories, x
means:
-
You can enter (cd into) the directory
-
Without it, even if you can read files, you canβt enter the folder
π How to Change Permissions: chmod
β³οΈ Symbolic Method
chmod [who]+/-[permission] filename
Who | Description |
---|---|
| user (owner) |
| group |
| others |
| all (user + group + others) |
β Examples:
chmod u+x script.sh # Add execute to user
chmod g-w file.txt # Remove write from group
chmod o+r report.txt # Add read for others
chmod a-x script.sh # Remove execute for everyone
π’ Numeric Method (Octal)
Permissions also have numeric values:
Permission | Value |
---|---|
| 4 |
| 2 |
| 1 |
You add them up:
Symbol | Value | Meaning |
---|---|---|
| 6 | 4+2 |
| 4 | read only |
| 7 | full access |
β Example:
chmod 755 script.sh
Breakdown:
-
7
= user βrwx
-
5
= group βr-x
-
5
= others βr-x
Another one:
chmod 644 file.txt
Means:
-
User: read+write (6)
-
Group: read only (4)
-
Others: read only (4)
π Bonus: Default Permissions & umask
Every time you create a file/folder, Linux assigns default permissions, which are affected by a value called umask
.
β Check umask:
umask
Common default is 0022
, meaning:
-
Files default to
644
-
Directories default to
755
To permanently change umask, modify:
~/.bashrc
or/etc/bashrc
for global changes
π Verify File Ownership
Use ls -l
to check the owner and group:
-rw-r--r-- 1 alice developers 1234 Jul 7 12:00 file.txt
To change ownership:
sudo chown bob:designers file.txt
π§ͺ Most Common RHCSA Scenarios
Scenario | Command |
---|---|
Make script executable |
|
Secure private key file |
|
Make directory accessible to all |
|
Remove all access for others |
|
β Summary / Key Takeaways
Command | Description |
---|---|
| Change permission |
| Change owner/group |
| View permissions |
| Show default permission mask |
π Remember:
-
Use symbolic method for readability
-
Use numeric (octal) for scripting or when you know exact values
-
File vs directory permissions behave slightly differently
-
Practice both methods for RHCSA exam
π¬ Final Words
Understanding permissions is essential for system security and file control. Once you grasp the concept, chmod
becomes your daily command as a sysadmin!