Where OWNER is the username of the owner of the file, GROUP is the group-name of the group owner, FILE is the file, files, or directory to be changed, and OPTION is any of the following:
-c, --changes
like verbose but report only when a change is made
--dereference
affect the referent of each symbolic link, rather than the symbolic link itself
-h, --no-dereference
affect symbolic links instead of any referenced file (available only on systems that can change the ownership of a symlink)
--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. Either may be omitted, in which case a match is not required for the omitted attribute.
-f, --silent, --quiet
suppress most error messages
--reference=RFILE
use RFILE's owner and group rather than the specified OWNER:GROUP values
-R, --recursive
operate on files and directories recursively
-v, --verbose
output a diagnostic for every file processed
--help
display this list of options and exit
--version
output version information and exit
If I was changing a file "foobar" to be owned by the user "frank" and the group "business" then the command would be:
# chown frank:business foobar
If I wanted to change the directory "somedir" to be owned by user "clarke" and the group "mainoffice", and I wanted all files underneath somedir to gain this ownership as well, I would issue:
# chown -R clarke:mainoffice somedir/
Note that on some UNIXes, it is equally valid to use a period (".") character in place of the colon separator (":"). For example, the following is generally equivalent to the previos command
# chown -R clarke.mainoffice somedir/
chgrp
chgrp changes the group ownership of a given file or directory. Because it's functionality is duplicated in chown, chgrp is not used as often anymore. chgrp usage is very similar to chown:
chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...
and it accepts the same options as chown. Thus, we will not go into much depth with them.
If I wanted to change the group owner of the file "airplane.txt" to group "users", I would issue the following command