chown Command Examples in Linux

The chown command is used to change the owner, the group, or both for a file or directory. At times, you may wish for someone else to manage an object’s permissions other than the user who created that object. You can combine the chown command with the -R option to recursively change ownership through a directory structure.

Syntax

chown command can be used in various ways as shown below:

1. Change owner:

# chown {user name} {file/directory name}

2. Change owner and group:

# chown {user name}:{group name} {file/directory name}

3. Change owner and change group to specified user’s login group:

# chown {user name}: {file/directory name}

4. Change group:

# chown {user name} {file/directory name}

chown Command Examples

1. To change the owner of the file:

# chown mike file.txt 

2. To see if the changes have taken place or not:

# chown -c mike file.txt 

3. To suppress if any error messages:

# chown -f mike file.txt 

4. To apply the changes recursively:

# chown -R mike /mydir 

5. To change the file owner and group at once:

# chown mike:SUPPORT file.txt 
Related Post