6. Create and Configure File Systems
πRed Hat Certified System Administrator (RHCSA β EX200)
In IT systems, file permissions are rules that control who can read, write, or execute a file or folder. Understanding and fixing permission problems is essential to ensure that users and applications can access files safely without causing security issues.
1. Understanding File Permissions in Linux
Linux (and Unix-based systems) uses three main permission types for three different groups:
Permission types:
- Read (r): Allows viewing the file content.
- Write (w): Allows modifying the file content.
- Execute (x): Allows running the file as a program or script.
Groups:
- Owner: The user who owns the file.
- Group: Other users in the same group as the file.
- Others: All other users on the system.
Example:
-rwxrw-r--
rwxβ Owner can read, write, and execute.rw-β Group can read and write.r--β Others can only read.
2. Checking Permissions
To diagnose permission issues, first check who owns the file and its current permissions:
ls -l /path/to/file
Output example:
-rw-r--r-- 1 alice developers 1024 Mar 12 10:30 report.txt
- Owner: alice
- Group: developers
- Permissions:
rw-for owner,r--for group and others.
3. Common Permission Problems
- User cannot read a file
- Cause: Read permission missing.
- Example: cat report.txt If denied, check permissions.
- User cannot write to a file
- Cause: Write permission missing or file is owned by another user.
- Example: echo “Update” >> report.txt
- User cannot execute a script
- Cause: Execute permission missing.
- Example: ./backup.sh
- Access denied even with correct permissions
- Cause: File may be on a mounted filesystem with restricted permissions (like NFS) or ACL issues.
4. Correcting Permissions
You can change file permissions using the chmod command.
Syntax:
chmod [options] permissions file
Two ways to specify permissions:
- Symbolic: Using letters chmod u+x script.sh # Adds execute for owner
chmod g-w report.txt # Removes write for group
chmod o+r file.txt # Adds read for othersuβ owner (user)gβ groupoβ others+β add permission-β remove permission=β set exact permission
- Numeric (Octal):
Each permission has a number:- Read = 4
- Write = 2
- Execute = 1
Add them up for each group:
- Owner: 7 (4+2+1 β rwx)
- Group: 5 (4+0+1 β r-x)
- Others: 5 (r-x)
5. Correcting Ownership
Sometimes, permission issues occur because the wrong user or group owns the file.
Use the chown command:
chown owner:group /path/to/file
Example:
chown alice:developers report.txt
- Changes the owner to alice
- Changes the group to developers
6. Advanced Permissions: ACLs
In modern IT environments, Access Control Lists (ACLs) allow more detailed permissions.
Check ACLs:
getfacl /path/to/file
Set ACLs:
setfacl -m u:bob:rw file.txt # Give user bob read/write
ACLs are useful when multiple users need different levels of access that the standard owner/group/others model cannot handle.
7. Diagnosing Permission Problems
Step-by-step approach:
- Check current permissions: ls -l file.txt
- Check ownership: ls -l file.txt
- Verify owner and group.
- Check ACLs (if normal permissions are correct but access is still denied): getfacl file.txt
- Check mount options (for network drives or external storage):
- Some mounts can be read-only:
- Correct permissions or ownership:
- Use
chmodandchownas needed.
- Use
8. IT Environment Examples
- Web server files
- Apache or Nginx must read website files.
- Commands: chown www-data:www-data /var/www/html/index.html
chmod 644 /var/www/html/index.html
- Scripts for automated tasks
- Must be executable by the automation user.
- Command: chmod +x /usr/local/bin/backup.sh
- Shared project folder
- Multiple developers need read/write.
- Commands: chown -R alice:developers /srv/projects
chmod -R 770 /srv/projects
9. Key Commands to Remember for the Exam
| Task | Command Example |
|---|---|
| View permissions | ls -l filename |
| Change permissions | chmod 755 script.sh |
| Change owner | chown alice file.txt |
| Check ACL | getfacl file.txt |
| Set ACL | setfacl -m u:bob:rw file.txt |
| Diagnose mount permissions | `mount |
10. Exam Tips
- Always check owner, group, and permissions before making changes.
- Remember the order: diagnose β fix permissions β fix ownership β check ACLs.
- Numeric (
chmod 755) and symbolic (chmod u+x) are both acceptable on the exam. - Understand practical scenarios like web servers, scripts, shared folders.
This covers everything necessary for Sub-topic 6.5 for your exam in a clear, IT-focused way.
