chown
Quick Reference
Command Name:
chown
Category:
file ownership
Platform:
linux
Basic Usage:
Common Use Cases
Syntax
chown [OPTION]... [OWNER][:[GROUP]] FILE... chown [OPTION]... --reference=RFILE FILE...
Options
Option | Description |
---|---|
-c, --changes | Like verbose but report only when a change is made |
-f, --silent, --quiet | Suppress most error messages |
-v, --verbose | Output a diagnostic for every file processed |
--dereference | Affect the referent of each symbolic link (default), rather than the symbolic link itself |
-h, --no-dereference | Affect symbolic links instead of any referenced file |
--from=CURRENT_OWNER:CURRENT_GROUP | Change the owner and/or group only if current owner/group match specified values |
--no-preserve-root | Do not treat '/' specially (the default) |
--preserve-root | Fail to operate recursively on '/' |
--reference=RFILE | Use RFILE's owner and group rather than specifying values |
-R, --recursive | Operate on files and directories recursively |
-H | If a command line argument is a symbolic link to a directory, traverse it (with -R only) |
-L | Traverse every symbolic link to a directory encountered (with -R only) |
-P | Do not traverse any symbolic links (default) (with -R only) |
--help | Display help message and exit |
--version | Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the chown
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
# Change the owner of a file chown user1 filename.txt
Advanced Examples:
# Recursively change owner and group for a directory and its contents chown -R www-data:www-data /var/www/html