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.

6 steps
Press Play and the tutor will talk you through it while writing on the board. Pause any time to write on the board yourself.

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
Ownerlearner4 + 2 + 0 = 6
Grouplearner2 (in labgroup)4 + 2 + 0 = 6
Othersguest (everyone else)4 + 0 + 0 = 4
-rw-rw-r--=chmod 664

🧑 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.

/home
→
/home/learner
→
lab/
→
notes.txt

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:

PositionExampleMeaning
1-Type: - file, d directory, l link
2–4rw-Owner (learner) can read and write
5–7r--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)
0 of 6 answered

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.

Practice challenge 02: a private notes file

1. Check the current permissions on notes.txt.

learner@ubuntu-lab:~/lab$

Check your understanding0 of 3 correct

Question 1

1.What does chmod 640 allow?

Question 2

2.Can a file with readable mode bits still be inaccessible?

Question 3

3.A web app can't read its config file, and someone suggests chmod 777. Why is that a bad fix?

Quiz score: 0 of 3

Tip: answer every quiz question correctly first.

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.