Permissions & Ownership – Linux Teaching Plan

This 3‑hour module equips students with the skills to set, modify, audit and troubleshoot Linux file and directory permissions and ownership. The plan is designed for users who already know how to navigate the filesystem and want to enforce security policies.

Learning Objectives

Schedule & Topics

  1. Introduction & ls -l (5 min)
  2. Octal vs Symbolic chmod (10 min)
  3. Ownership with chown & chgrp (10 min)
  4. Default bits – umask (10 min)
  5. Special modes – setuid, setgid, sticky (10 min)
  6. Access Control Lists – getfacl & setfacl (15 min)
  7. Auditing – stat, find -perm, find -user (15 min)
  8. Problem‑solving – common permission errors (10 min)
  9. Mini‑project & Automation (15 min)
  10. Q&A & Wrap‑up (10 min)

Command Topics & Hands‑On Exercises

1. ls -l – List with Permissions

Shows file mode, owner, group, size and timestamps.

ls -l /home/youruser
ls -l file.txt

2. stat – Detailed File Information

Displays inode, device, permissions, ownership, timestamps, etc.

stat file.txt
stat --format '%A %n' file.txt

3. chmod – Octal Notation

Sets permissions by numeric value.

chmod 644 file.txt
chmod 600 script.sh
chmod 777 directory

4. chmod – Symbolic Notation

Uses characters to modify permission bits.

chmod u+x file.txt
chmod g-w file.txt
chmod o= file.txt
chmod u=rwx,g=rx,o= file.txt

5. chown – Change Owner

Reassigns file or directory owner (and optionally group).

chown user file.txt
chown user:group file.txt
chown -R user:group dir/

6. chgrp – Change Group

Reassigns the group of a file or directory.

chgrp staff file.txt
chgrp -R staff dir/

7. umask – Default Permission Mask

Defines the default permission bits for newly created files/directories.

umask
umask 022
umask 027
umask 077

8. getfacl – Display ACLs

Shows extended ACL entries for a file or directory.

getfacl file.txt
getfacl -R dir/

9. setfacl – Modify ACLs

Adds or removes ACL entries.

setfacl -m u:alice:rw file.txt
setfacl -m g:devops:r-- dir/
setfacl -b file.txt           # remove all ACLs

10. find -perm – Search by Permission Bits

Finds files that match specific permission patterns.

find . -perm 644 -type f
find /tmp -perm /g=w   # files writable by group
find /tmp -perm -g=w  # files with group write bit set

11. find -user/-group – Search by Owner or Group

Locates files based on current owner or group.

find /var/log -user root -type f
find /tmp -group staff -type d

12. chmod g+s – SetGID on a Directory

Ensures new files inherit the directory’s group.

chmod g+s project/
ls -ld project/

13. chmod +t – Sticky Bit

Prevents users from deleting files that they don’t own in a shared directory.

chmod +t /tmp/shared
ls -ld /tmp/shared

14. getent passwd / getent group – View Users & Groups

Displays the system’s user and group database.

getent passwd | grep alice
getent group | grep devops

15. id – Show User/Group IDs

Prints real, effective, saved, and supplementary group IDs.

id
id alice
id -Gn

16. auditd – Permission Auditing (optional)

Demonstrates how to audit permission changes.

# install auditd on the test machine
sudo apt-get install auditd
sudo auditctl -w /home/youruser -p wa -k home_changes
sudo ausearch -k home_changes

Practice Workshop (Hands‑On)

Students are paired and each receives a /tmp/perm_tutorial folder pre‑populated with files and directories of varying ownership/permissions. They will complete all the exercises, then exchange their setups for peer review.

Assessment

  1. Quiz (5 min): 5 rapid questions about notation, command syntax and expected output.
  2. Mini‑Project (15 min): Write a script that:
    1. Creates a directory /tmp/safe with permissions 2750 (setgid + r-x for owner & group).
    2. Copies all .conf files from /etc into it.
    3. Sets ACL to allow user alice full access while denying all other users.
    4. Prints the final permission state with getfacl.
  3. Peer review: each student runs another’s script and comments on correctness.

Resources & Further Reading

Feel free to adjust the pacing or replace optional commands (e.g., auditd) with other tools such as selinux commands if your audience already knows ACLs.