chown Command: Tutorial & Examples

Change the owner of a file or directory

The chown command is a Unix and Linux command used to change the ownership of a file or directory. It stands for "change owner." The chown command allows you to change the owner of a file or directory, as well as the group owner.

Here is the basic syntax for the chown command:

chown owner file

Here, owner is the name of the user or group that you want to set as the owner of the file or directory. file is the name of the file or directory whose ownership you want to change.

You can also specify the group owner using the following syntax:

chown owner:group file

Here, group is the name of the group that you want to set as the group owner of the file or directory.

You can use the -R option to recursively change the ownership of a directory and all of its contents. For example:

chown -R owner:group directory

This would change the ownership of directory and all of its contents to the specified owner and group.

Note that you must have the appropriate permissions to use the chown command. Only the owner of a file or directory, or a user with superuser privileges, can change its ownership.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA