Skip to main content

chown

The chown (change owner) command is used to change the user owner and/or the group owner of a given file, directory, or symbolic link. Typically, only the root user can change the ownership of a file to another user.

Basic Syntax

chown [OPTION]... [OWNER][:[GROUP]] FILE...

Common Options

OptionDescription
-R, --recursiveOperate on files and directories recursively.
-v, --verboseOutput a diagnostic for every file processed.
-c, --changesLike verbose but report only when a change is made.
--reference=RFILEUse RFILE's owner and group rather than specifying them.

Real-world Examples

  1. Change the owner of a file:

    sudo chown john document.txt
  2. Change both the owner and group of a file:

    sudo chown john:developers project.zip
  3. Change only the group of a file:

    sudo chown :developers shared_folder

    (Similar to chgrp)

  4. Change ownership recursively for a directory:

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