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, --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.
--from=CURRENT_OWNER:CURRENT_GROUPChange the owner and/or group of each file only if its current owner and/or group match those specified here.
--reference=RFILEUse RFILE's owner and group rather than specifying OWNER:GROUP values.
-h, --no-dereferenceAffect symbolic links themselves instead of the files they point to (useful only on systems that can change the ownership of a symlink).
--silent, --quietSuppress most error messages.
Examples
Changes the owner of myfile.txt to newuser.
Changes the group ownership of important_dir to newgroup.
Changes both the owner to user1 and group to group1 for report.doc.
Recursively changes ownership of all files and directories in /home/dave/public_html to user dave.
Changes ownership of somefile to newuser:newgroup only if it was previously owned by olduser:oldgroup, and reports the change.
Makes /etc/shadow have the same owner and group as /etc/passwd.