1. Home
  2. Linux
  3. Linux File Permissions
  4. Linux – chown

Linux – chown

Linux chown command

Linux chown command is used for changing the owner or group owner of a file or directory.

Syntax:

chown <USER>[:<GROUP>] [FILE]...

Example:

Set the file owner of testfile.txt to user “rahul”.

chown rahul testfile.txt

Set the file owner of testfile.txt to user “rahul” and also set the group owner to “root”.

chown rahul:root testfile.txt

Change File Ownership Recursively

You can specify option -R to change owner and group recursively to all files in the specified directory an subdirectory. For example, set Apache user permission to all files under /var/www/html directory.

chown -R www-data:www-data /var/www/data