KIM COMPUTER


chown (Change Owner)

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


1. Basic Usage

chown [options] [user][:group] filename

2. Common Usage Patterns

Command Format Description
chown kim file.txt Changes the owner to kim.
chown :dev file.txt Changes the group to dev.
chown kim:dev file.txt Changes both the owner to kim and group to dev.
chown kim: file.txt Changes the owner to kim and the group to kim's primary group.

3. Key Options

Option Name Description
-R recursive Recursive. Operates on files and directories recursively.
-v verbose Displays a message for every file processed.
-c changes Like verbose, but reports only when a change is actually made.
--reference reference Uses the ownership of a reference file instead of specifying a user/group.

4. Practical Examples

① Changing Web Root Ownership

Ensuring the web server has correct permissions for all files in the web root:

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

② Changing Ownership of a Symbolic Link

To change the owner of the link itself rather than the file it points to, use -h:

sudo chown -h kim symbolic_link

5. [Tip] chmod vs. chown