How to Change File Ownership with the Linux chown Command
The chown command changes which user and group own a file. You need root privileges, so run it with sudo. sudo chown alice notes.txt makes alice the owner, and sudo chown alice:staff notes.txt sets the group too.
Change the owner
Pass the new owner followed by the file. Only root can do this, hence the sudo prefix.
Change owner and group together
Use the user:group form to set both at once. This is how you hand a file to a team member and their project group in one command.
Change only the group
Leave the owner blank before the colon to change just the group: :developers.
Apply to a whole tree with -R
Use -R to change ownership recursively. A common fix after unpacking a website is to hand the folder to the web server user:
Chown vs chmod
chown sets who owns a file; chmod sets what they may do with it. Ownership and permissions together decide access. Check the current owner with ls -l. See chown for the full reference.
Keep learning
Related guides: Linux chmod Command: A Complete Permissions Guide · Linux User Management: useradd, usermod and passwd · The Linux ls Command: List Files Like a Pro. Read all tutorials on the Learn Linux blog.