File permissions: read, write, execute and chmod
You read the permissions in ls -l output and grant and remove them with letter and number chmod; you learn how umask shapes new files, how the sticky bit protects shared folders and how to audit the most dangerous permission, setuid. You test every change with the intern account.
Level 101 · 45 min
A new intern has joined Northwind and has an account called intern on the server. Daniel is worried: "Make sure the intern can’t see what they shouldn’t. If an account is taken over, the attacker sees exactly what that account sees."
On Linux every file has three permissions for three kinds of people. The people: the file’s owner (user, u), the file’s group (g) and everyone else (others, o). The permissions: read (r), write (w) and execute (x).
Analogy: a flat. The owner’s key opens every door, family members enter some rooms, guests only the living room. Permissions write down which key opens which door.
Help fades as the lesson goes on: in the first steps one button types a command into the terminal, in the middle you type yourself, and in the last steps only the goal is given. If you get stuck, look at the hint; after two wrong tries the solution appears.
What you will do in this lesson
- Read the permissions: ls -l
- Give the script execute permission: chmod u+x
- Lock the password file: chmod 600
- Directory permissions: chmod 750
- Write the permission from scratch: chmod u=,g=,o=
- What permissions are new files born with? umask
- Someone else’s file in a shared folder: the sticky bit
- Find and close the files everyone can write to
- The most dangerous permission: a setuid audit
- Short quiz
Skills you will earn
- Reading a permission string (rwxr-x---)
- Changing permissions with letters (chmod u+x, o-w)
- Setting permissions with numbers (chmod 600, 750)
- Testing a setting as another user (su -c)
- Knowing what r, w and x mean on directories
- Writing a permission from scratch (chmod u=rwx,g=rx,o=)
- Setting new files’ permissions with umask
- Protecting a shared folder with the sticky bit (chmod +t)
- Searching for risky permissions (find -perm)
- Auditing setuid files and defusing a back door
← Quick task: find the altered configuration file · Linux quick start · Changing ownership: chown and chgrp →
Start for free