chown Command
Beginner Permissions & Ownership man(1)Change file owner and group
👁 9 views
📅 Updated: Mar 15, 2026
SYNTAX
chown [OPTION]... OWNER[:GROUP] FILE...
What Does chown Do?
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.
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.
Options & Flags
| Option | Description | Example |
|---|---|---|
| user:group | Change both owner and group | chown www-data:www-data file.php |
| user | Change owner only | chown admin file.txt |
| :group | Change group only | chown :developers project/ |
| -R | Recursive | chown -R www-data:www-data /var/www/ |
| --reference | Copy ownership from another file | chown --reference=index.html new_page.html |
| -v | Verbose — show changes | chown -Rv www-data /var/www/ |
Practical Examples
#1 Change owner and group
Sets both owner and group to www-data (web server).
$ sudo chown www-data:www-data /var/www/html/#2 Recursive ownership
Changes ownership of entire application directory.
$ sudo chown -R deploy:deploy /opt/myapp/#3 Change group only
Changes only the group, leaving owner unchanged.
$ sudo chown :developers /shared/project/#4 Fix home directory
Fixes ownership after accidentally changing home directory permissions.
$ sudo chown -R user:user /home/user/#5 Web deployment
Complete web deployment: set ownership and permissions.
$ sudo chown -R www-data:www-data /var/www/html/ && sudo find /var/www/html/ -type d -exec chmod 755 {} \; && sudo find /var/www/html/ -type f -exec chmod 644 {} \;#6 Copy ownership
Copies the ownership from one file to another.
$ chown --reference=existing_file.txt new_file.txtTips & Best Practices
Requires root: Only root can change file ownership. Use sudo chown. Regular users can only change the group to a group they belong to.
Use user:group syntax: chown user:group file changes both at once. This is more efficient than separate chown and chgrp commands.
Numeric IDs: chown 1000:33 file works with numeric UIDs and GIDs. Useful when username does not exist on the current system.
Frequently Asked Questions
How do I change file ownership?
sudo chown user:group filename. For recursive: sudo chown -R user:group directory/
How do I set web server permissions?
sudo chown -R www-data:www-data /var/www/html/ sets the web server as owner.
Can I change ownership without root?
No — changing the owner requires root. You can change the group to any group you belong to using chgrp.
Related Commands
More Permissions & Ownership Commands
Master Linux with Professional eBooks
Curated IT eBooks covering Linux, DevOps, Cloud, and more
Browse Books →