Linux Commands - chown (change ownership)

by
Jeremy Canfield |
Updated: March 30 2021
| Linux Commands articles
The chown command can be used to change the owner of a file or directory. Let's say /tmp/foo.txt is owned by John Doe.
~]$ ls -l /tmp
-rw-r--r--. 1 john.doe john.doe 123 Sep 25 08:52 foo.txt
john.doe or root can use the chown command to update foo.txt to be owned by someone else. In this example, John Doe updates foo.txt to be owned by jane.doe.
[john.doe@server1 ~]$ chown jane.doe /tmp/foo.txt
Now foo.txt is owned by Jane Doe.
~]$ ls -l /tmp
-rw-r--r--. 1 jane.doe john.doe 123 Sep 25 08:52 foo.txt
Resursive
The -R or --recursive flag can be used to change the ownership of every file at and below a directory. In this example, every file at and below the /tmp directory will be updated to be owned by root.
[root@server1 ~]$ chown --recursive root /tmp
Change Owner and Group
The chgrp (change group) command can be used to change the group of a file or directory. Or, the owner and group can be changed using the chown command, like this.
~]$ chown jane.doe:admins /tmp/foo.txt
Did you find this article helpful?
If so, consider buying me a coffee over at