๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout Register Now โ†’
Menu

Categories

๐Ÿ’ก Permissions & Ownership October 14, 2026 9

Linux Command: chown

Change file owner and group

Terminal โ€” Permissions & Ownership
Command
$ sudo chown www-data:www-data /var/www/html/

chown (change owner) changes the user and/or group ownership of files and directories. File ownership determines which permission set (user, group, other) applies to each user accessing the file. chown requires root privileges (or ownership of the file on some systems). It can change the owner, the group, or both simultaneously with the user:group syntax. chown is essential for web server setup (changing files to www-data), application deployment, and fixing ownership after file transfers or extractions.

Syntax

chown [OPTION]... OWNER[:GROUP] FILE...

Key Options

  • user:group โ€” Change both owner and group
  • user โ€” Change owner only
  • :group โ€” Change group only
  • -R โ€” Recursive
  • --reference โ€” Copy ownership from another file
  • -v โ€” Verbose โ€” show changes

Examples

Change owner and group

sudo chown www-data:www-data /var/www/html/

Recursive ownership

sudo chown -R deploy:deploy /opt/myapp/

Change group only

sudo chown :developers /shared/project/

Pro Tips

  • Only root can change file ownership. Use sudo chown. Regular users can only change the group to a group they belong to.
  • chown user:group file changes both at once. This is more efficient than separate chown and chgrp commands.
  • chown 1000:33 file works with numeric UIDs and GIDs. Useful when username does not exist on the current system.

Learn more: Full chown reference โ†’

Share this tip