1. Understand and Use Essential Tools
πRed Hat Certified System Administrator (RHCSA β EX200)
1. Understanding File Permissions in Linux
Linux is a multi-user system. Each file and directory has permissions that control who can do what with them.
Permissions are set for three types of users:
- u (user / owner) β The person who owns the file.
- g (group) β Other users in the same group as the file.
- o (others) β Everyone else on the system.
There are three types of actions each user can perform:
| Permission | Meaning | Symbol |
|---|---|---|
| Read | View the file or list directory contents | r |
| Write | Modify the file or add/remove files in a directory | w |
| Execute | Run the file as a program or access a directory | x |
So, for each file, Linux tracks who can read, write, and execute it for the owner, group, and others. This is called ugo/rwx permissions.
2. Viewing Permissions (ls -l)
To see permissions, use:
ls -l filename
Example:
-rwxr--r-- 1 alice devs 1024 Feb 19 12:00 script.sh
Breakdown:
-β Type of file (-regular file,ddirectory,lsymbolic link)rwxβ Owner (user) permissions: read, write, executer--β Group permissions: read onlyr--β Others permissions: read onlyaliceβ Ownerdevsβ Group1024β File size in bytesscript.shβ File name
Tip: Directories show permissions differently: x on a directory allows you to enter it. r allows you to list its files. w allows you to create/delete files inside it.
3. Changing Permissions (chmod)
You can change permissions using chmod. There are two ways:
3.1 Symbolic Method
Use letters to specify who and what:
uβ usergβ groupoβ othersaβ all (u+g+o)
Operators:
+β add permission-β remove permission=β set exact permission
Examples:
- Add execute permission for owner:
chmod u+x script.sh
- Remove write permission from group:
chmod g-w data.txt
- Give read/write to everyone:
chmod a+rw report.txt
- Set exact permissions: read/write for owner, read-only for group, none for others:
chmod u=rw,g=r,o= file.txt
3.2 Numeric (Octal) Method
Linux also allows numbers for permissions:
r= 4w= 2x= 1
Add them to get the permission number.
Example Table:
| Permission | Number |
|---|---|
rwx | 4+2+1 = 7 |
rw- | 4+2+0 = 6 |
r-- | 4+0+0 = 4 |
--x | 0+0+1 = 1 |
--- | 0 |
Example usage:
chmod 754 script.sh
Breakdown:
7β owner: rwx5β group: r-x4β others: r–- Result:
-rwxr-xr--
This method is common in scripts or automation, because itβs faster than symbolic.
4. Changing Ownership (chown)
Permissions work with owners. Sometimes you also need to change the owner or group:
chown newuser filename # change owner
chown :newgroup filename # change group
chown newuser:newgroup filename # change both
Example:
chown alice:devs script.sh
Now alice owns the file and the group devs has its group permissions.
5. Practical IT Examples
- Scripts for Automation
- Script
backup.shshould be rwx for owner only, so others canβt change it:
chmod 700 backup.sh
- Shared Project Directory
- Directory
/projectshared among groupdevs. Team can read/write, others cannot:
chown :devs /project
chmod 770 /project
- Public Logs
- Log file
/var/log/app.logreadable by everyone, only root can modify:
chmod 644 /var/log/app.log
6. Summary for Exam
| Task | Command Example |
|---|---|
| List permissions | ls -l filename |
| Add permission | chmod u+x file |
| Remove permission | chmod g-w file |
| Set exact permissions | chmod u=rw,g=r,o= file |
| Numeric permissions | chmod 754 file |
| Change owner | chown user file |
| Change group | chown :group file |
| Change both | chown user:group file |
Remember for RHCSA:
- You must view, set, and change permissions using both symbolic and numeric methods.
- You must change ownership when required.
- Understand rwx for user, group, others.
- Practice on files and directories.
