World map

 

BM: Baca dalam Bahasa Melayu

World L2: Keys & Staff

Change the owner: chown

You will learn: to hand a file or folder to another user or group with sudo chown.

Checked with Linux (Debian 13) on 1 Nov 2026

The problem

Customers upload photos of their food. The web staff, user www-data, saves them in /srv/kedai/uploads. Every upload fails. Why?

Pick one answer.

Watch

you@kedai:/srv/kedai
ls -l
total 8
-rw-r--r-- 1 you you 14 Nov 1 08:55 menu.html
drwxr-xr-x 2 you you 4096 Nov 1 08:55 uploads
sudo -u www-data touch uploads/a.jpg
touch: cannot touch 'uploads/a.jpg': Permission denied
ls -l, then the web staff tries to save a photo: Permission denied.

sudo -u www-data runs one command as the web staff. Real error: Permission denied. Plain words: uploads is yours, and others have no w key.

Predict

You own uploads. Can you give it away yourself with chown www-data uploads?

Pick one answer.

Try it

Hand the folder to the web staff and their group: sudo chown www-data:www-data uploads.

You are you in /srv/kedai. 2 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:/srv/kedai$

Folder /srv/kedai

  • menu.html (file)-rw-r--r--
  • uploads/ (folder)drwxr-xr-x

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Check

chmod or chown? Pick the right tool.

Drag a card into a box. Or tap the card, then tap the box.

      Try it

      The folder is handed over. Test it as the web staff: sudo -u www-data touch uploads/a.jpg.

      You are you in /srv/kedai. 2 things here. Services: cron running, ssh running, nginx running.

      You are hereyou@kedai:/srv/kedai$

      Folder /srv/kedai

      • menu.html (file)-rw-r--r--
      • uploads/ (folder)drwxr-xr-xnot yours

      Services

      • cronrunningstarts at boot
      • sshrunningstarts at boot
      • nginxrunningstarts at boot

      You did it!

      You can now hand files and folders to the right owner.

      Go deeper (optional)

      sudo chown -R www-data:www-data uploads changes a folder and everything inside: check the path twice. sudo chown :kitchen roster.txt changes only the group. Never hand your whole home to another user.

      Real rep (optional): on Linux, ls -l /var/www shows who owns the web files.