How to Change File Ownership in Linux (chown)

chown changes which user and group owns a file or directory.

Published October 1, 2026

chown changes the owner and group of files and directories. Only root (or sudo) can give files to other users.

How it works

Syntax: chown user:group path. Use -R for recursion. chgrp changes only the group.

Web servers often need the right ownership (for example www-data) to write to uploads or logs.

Try it

sudo chown -R www-data:www-data /var/www/uploads
ls -ld /var/www/uploads
drwxr-xr-x 2 www-data www-data

Practical examples

Change owner

sudo chown ada file.txt

Owner and group

sudo chown ada:dev file.txt

Recursive

sudo chown -R www-data: /var/www/site

Copy ownership from a reference file

sudo chown --reference=a.txt b.txt

Common mistakes

  • Recursive chown on / or system directories.
  • Following symlinks into unexpected places.
  • Fixing permissions with chmod 777 instead of correct ownership.

Key takeaways

  • chown user:group path.
  • -R is recursive.
  • Needs sudo.

FAQ

chown vs chmod?

chown changes who owns; chmod changes what they can do.

How do I see owners?

ls -l.

More Linux articles