Skip to content
ohsudo, Home

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

  1. 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.
  2. The wall. You can read this folder, because everyone has r and x. You can't write in it, as only the owner has w.
  3. Run it as root. sudo runs 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.
  4. Who runs what?. whoami prints your user, and with sudo you can see the difference. A file created with sudo belongs to root, which is a classic reason for later permission errors.
  5. Hand it to the web server. chown changes the owner, and only root can do that. On Debian and Ubuntu, the web server runs as www-data. chown changes the owner, and only root can do that. On RHEL, Rocky and AlmaLinux, Nginx runs as the user nginx, not www-data as on Debian and Ubuntu.
  6. A whole folder. -R applies to everything inside too. Now the folder is yours, and you don't need sudo to work in it. Be careful with -R on system folders, as it's hard to undo.

See also