HxHippy

chown

Change file owner and group

Overview

Changes the user and/or group ownership of each given file. The owner and group can be specified as OWNER, :GROUP, or OWNER:GROUP.

Syntax

chown [OPTION]... [OWNER][:[GROUP]] FILE...
chown [OPTION]... --reference=RFILE FILE...

Common Options

-R, --recursive

Operate on files and directories recursively.

-v, --verbose

Output a diagnostic for every file processed.

-c, --changes

Like verbose but report only when a change is made.

--from=CURRENT_OWNER:CURRENT_GROUP

Change the owner and/or group of each file only if its current owner and/or group match those specified here.

--reference=RFILE

Use RFILE's owner and group rather than specifying OWNER:GROUP values.

-h, --no-dereference

Affect symbolic links themselves instead of the files they point to (useful only on systems that can change the ownership of a symlink).

--silent, --quiet

Suppress most error messages.

Examples

$ sudo chown newuser myfile.txt

Changes the owner of myfile.txt to newuser.

$ sudo chown :newgroup important_dir

Changes the group ownership of important_dir to newgroup.

$ sudo chown user1:group1 report.doc

Changes both the owner to user1 and group to group1 for report.doc.

$ sudo chown -R dave /home/dave/public_html

Recursively changes ownership of all files and directories in /home/dave/public_html to user dave.

$ sudo chown -c --from=olduser:oldgroup newuser:newgroup somefile

Changes ownership of somefile to newuser:newgroup only if it was previously owned by olduser:oldgroup, and reports the change.

$ sudo chown --reference=/etc/passwd /etc/shadow

Makes /etc/shadow have the same owner and group as /etc/passwd.

ownergrouppermissionsfiledirectorysecuritychange ownerchown