Linux Labs

Users, permissions, and processes / Stage 2 of 13

File and directory permissions

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 6 · on a machine · 5 min

Your file, someone else's read

What you will learn

  • Read the owner, the group, and the three permission triples in ls -l output.
  • Tell what r, w, and x do on a file and on a directory.
  • Explain a denial by the process's account and the directories on the path to the file.

A colleague moved the weekly report into the shared directory /srv/permissions-lab and writes: "The report is yours now, and I opened it for everyone to read." Check who can actually read it.

Start prepares the directory and takes you there. The last command reads the report as www-data, the web server's account.

Exercise · look

Who can read the report

You are in /srv/permissions-lab. Run the three commands one by one: look at the file's line, read it yourself, and read it as www-data.

First, predict

ls -l will show you as the owner of report.txt. What will your cat report.txt print?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

Why was the owner of report.txt refused while www-data read the file?

  • www-data has UID 33: an ordinary account, not root. sudo -u www-data cat /etc/shadow gets Permission denied.

  • The directory is open: ls -l report.txt read the file's details, and cat reached the file and was refused the read.

  • sudo -u www-data runs the command as www-data: sudo -u www-data id prints uid=33(www-data). Without -u it would run as root.

The line -------r-- gives reading to others, and not to the owner student.

Ubuntu 24.04
Loading…