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.
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.
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/shadowgetsPermission denied. -
The directory is open:
ls -l report.txtread the file's details, andcatreached the file and was refused the read. -
sudo -u www-dataruns the command as www-data:sudo -u www-data idprintsuid=33(www-data). Without-uit would run as root.
The line -------r-- gives reading to others, and not to the owner student.