Module 1 · Linux Essentials for Security · Lesson 4 of 10
File permissions you can read at a glance
Read rwx strings, convert them to numbers like 640, and see why readable files can still be out of reach.
In this lesson · about 24 minutes
- Read and set owner, group and other permissions
- Convert between rwx and octal (r=4, w=2, x=1)
- Explain why directory traversal, ACLs and AppArmor also affect access
Whiteboard · watch and try
Whiteboard: turning rw-r----- into 640
Press Play. The tutor converts a permission string into a number, the trick everyone uses.
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
Try it · watch it happen
Permission builder: who may do what
Click the switches and watch the letters and the number change together. Then walk learner2 down the path to the file.
| 👀 Read (4) | ✏️ Write (2) | ▶️ Execute (1) | Adds up to | |
|---|---|---|---|---|
| Ownerlearner | 4 + 2 + 0 = 6 | |||
| Grouplearner2 (in labgroup) | 4 + 2 + 0 = 6 | |||
| Othersguest (everyone else) | 4 + 0 + 0 = 4 |
🧑 learner
✓ can open and read it
✓ can change it
✗ can run it as a program
👥 learner2 (in labgroup)
✓ can open and read it
✓ can change it
✗ can run it as a program
🌍 guest (everyone else)
✓ can open and read it
✗ can change it
✗ can run it as a program
Doors along the way: can learner2 reach /home/learner/lab/notes.txt?
To open a file you must pass through every folder before it. A folder's x permission is its door.
Run ls -l notes.txt and you'll see something like -rw-r----- 1 learner labgroup 120 notes.txt. The first ten characters are the mode:
| Position | Example | Meaning |
|---|---|---|
| 1 | - | Type: - file, d directory, l link |
| 2–4 | rw- | Owner (learner) can read and write |
| 5–7 | r-- | Group (labgroup) can read |
| 8–10 | --- | Others can do nothing |
Numbers
Each permission has a value: r = 4, w = 2, x = 1. Add them for each of owner, group and others: rw- = 6, r-- = 4, --- = 0. So rw-r----- is 640.
Directories are different
- r on a directory lets you list names in it.
- x lets you enter it and reach files inside (traversal). Without x on every parent folder, you can't reach a file even if the file itself is readable.
- w + x lets you create, rename and delete entries in it, even files you don't own (unless the sticky bit is set, as on
/tmp).
Beyond mode bits, ACLs (getfacl), mandatory access control like AppArmor or SELinux, and read-only mounts can also block access. Always test as the intended user.
Performance-based question (PBQ)
Convert the permissions
A teammate needs the octal value for each permission string before writing a hardening script.
Pick the octal mode for each.
- rw-r----- (private notes: owner edits, group reads)
- rw------- (an SSH private key)
- rw-r--r-- (a public web page)
- rwx------ (a home's .ssh folder)
- rwxr-xr-x (a program everyone may run)
- rwxr-x--- (a team script folder)
Hands-on lab (simulated terminal)
Practice challenge 02: a private notes file
Make notes.txt readable and writable by its owner (learner), readable by labgroup, and inaccessible to others. Sudo password: lab.
Step 1 of 6. Type each command and press Enter. Nothing runs on your computer.
1. Check the current permissions on notes.txt.
Check your understanding0 of 3 correct
Quiz score: 0 of 3
Noviq Academy is free and for learning. Every terminal here is simulated and every log is synthetic. Practise on a disposable VM with a snapshot, never on a production server. Ubuntu is a trademark of Canonical Ltd.; this course is independent of Canonical.