DEV Community

Cover image for 10.File Permission Correction
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

10.File Permission Correction

Lab Information

After conducting a security audit within the Stratos DC, the Nautilus security team discovered misconfigured permissions on critical files. To address this, corrective actions are being taken by the production support team. Specifically, the file named /etc/hosts on Nautilus App 2 server requires adjustments to its Access Control Lists (ACLs) as follows:

  1. The file's user owner and group owner should be set to root.

  2. Others should possess read only permissions on the file.

  3. User ammar must not have any permissions on the file.

  4. User jerome should be granted read only permission on the file.

Lab Solutions

🧭 Part 1: Lab Step-by-Step Guidelines (Technical Execution)

πŸ”Ή Step 1: Login to Jump Host
ssh thor@jump_host.stratos.xfusioncorp.com

Password:

mjolnir123

πŸ”Ή Step 2: Login to App Server 2
ssh steve@stapp02.stratos.xfusioncorp.com

Password:

Am3ric@

πŸ”Ή Step 3: Switch to root

sudo -i
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 4: Set owner and group to root

chown root:root /etc/hosts
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 5: Set base permissions (others read only)

chmod 644 /etc/hosts
Enter fullscreen mode Exit fullscreen mode

This ensures:

Owner β†’ rw-

Group β†’ r--

Others β†’ r--

πŸ”Ή Step 6: Remove all permissions for user ammar

setfacl -m u:ammar:--- /etc/hosts
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 7: Grant read-only permission to user jerome

setfacl -m u:jerome:r-- /etc/hosts
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Step 8: Verify ACL configuration

getfacl /etc/hosts
Enter fullscreen mode Exit fullscreen mode

Expected output should include:

user::rw-
user:ammar:---
user:jerome:r--
group::r--
other::r--

βœ… Final Checklist

βœ” Owner = root
βœ” Group = root
βœ” Permissions = 644
βœ” ammar has no permissions
βœ” jerome has read-only access
βœ” Verified using getfacl


🧠 Part 2: Simple Step-by-Step Explanation (Beginner Friendly)
πŸ”Ή Why use ACL instead of normal chmod?

Normal permissions allow control for:

Owner

Group

Others

But this task requires:

Specific rules for individual users (ammar, jerome)

That requires Access Control Lists (ACLs).

πŸ”Ή Step-by-step Logic
1️⃣ Set owner and group
chown root:root /etc/hosts

Ensures root fully controls the file.

2️⃣ Set base permission to 644
chmod 644 /etc/hosts

Means:

Owner β†’ read & write

Group β†’ read only

Others β†’ read only

3️⃣ Remove ammar’s access
setfacl -m u:ammar:---

Even if β€œothers” have read permission, this ACL explicitly overrides it for ammar.

4️⃣ Give jerome read-only access
setfacl -m u:jerome:r--

This ensures jerome can read even if future permission changes occur.

πŸ”Ή Why verify with getfacl?

ls -l will NOT show ACL entries.

Only:

getfacl /etc/hosts

confirms user-specific rules.

Resources & Next Steps
πŸ“¦ Full Code Repository: KodeKloud Learning Labs
πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
πŸ’Ό Let's Connect: LinkedIn - I'd love to connect with you

Credits
β€’ All labs are from: KodeKloud
β€’ I sincerely appreciate your provision of these valuable resources.

Top comments (0)