Linux Stuff && Coffee

Chown Command Linux & Examples

The chown command is used to change the ownership of one or more files & directories, here is the basic syntax:

chown [options] newowner files

Or you can copy the ownership details from another reference file:

chown [options] –reference=filename files

newowner is either a user ID number or a username from /etc/passwd. Chown can also change the group permission like this:

chown username:groupname files

Chown Examples

Here are some real word examples of the chown command in action.

Change all files in a dir to the user and group apache:

chown apache:apache *

Change all the files in the current dir and sub dir’s to the userand group apache:

chown -R apache:apache *

Change the owner of the ssh authorized_keys file for the user darth:

chown darth:darth /home/darth/.ssh/authorized_keys

Change the owner of the WordPress installation to the apache user to allow WordPress updates to work:

chown -R apache:apache /var/www/html

Chown Options

-c, –changes

Prints info about the files that are changed


Follow symbolic links

-f, –silent, –quiet

Do not print error messages about files that cannot be changed (stops errors displaying on the console).


Only changes the owner and group if they match the –from. If currown or currgroup is omitted, a match is not required.


Print information about all files that chown attempts to change, whether or not they are actually changed.

-R, –recursive

Traverse sub dirs recursively, applying changes.

-H       With -R, traverse symbolic link to a directory.

-L        With -R, traverse every sym link that leads to a dir.

-P         With -R, do not traverse any symbolic links. This is the
default option.

Change owner to the owner of filename instead of specifying a new owner explicitly.
Print help message and then exit.
Print version information and then exit.