Module 3: Permissions
Owners, chown and sudo
Permissions only make sense together with owners. Here you'll hit the most common wall on a server, a folder that belongs to root, and see the right ways past it.
● Runs 100% in your browser. Nothing here can harm a real system.
Step 1 of 6
Who owns this?
In ls -l, the two names after the permissions are the owner and the group. Here that's root for both, and you're guest.
Your task
List /srv/site with its details, and see who owns the file.
guest@ohsudo: ~ — Ubuntu 24.04
Starting the terminal…
What you'll practice
- Who owns this?. In
ls -l, the two names after the permissions are the owner and the group. Here that'srootfor both, and you'reguest. - The wall. You can read this folder, because everyone has
randx. You can't write in it, as only the owner hasw. - Run it as root.
sudoruns one command as root. It's the normal way to do admin work, as you're only root for that one command, and it gets logged. - Who runs what?.
whoamiprints your user, and withsudoyou can see the difference. A file created withsudobelongs to root, which is a classic reason for later permission errors. - Hand it to the web server.
chownchanges the owner, and only root can do that. On Debian and Ubuntu, the web server runs aswww-data.chownchanges the owner, and only root can do that. On RHEL, Rocky and AlmaLinux, Nginx runs as the usernginx, notwww-dataas on Debian and Ubuntu. - A whole folder.
-Rapplies to everything inside too. Now the folder is yours, and you don't needsudoto work in it. Be careful with-Ron system folders, as it's hard to undo.