chown(1)
Change the owner and/or group of files or directories.
Synopsis
chown [OPTION]... [OWNER][:[GROUP]] FILE...Description
chown changes the user and/or group ownership of each file. OWNER may be either a user name or numeric user ID (UID). GROUP may be either a group name or numeric group ID (GID). If only OWNER is given, that user becomes the owner and the group is unchanged. If OWNER:GROUP is given, both are changed. If only :GROUP is given, only the group is changed.
By default, chown does not follow symbolic links. Use -h to change the target of a symlink itself, or -L to follow symlinks when recursing directories.
Common options
| Flag | What it does |
|---|---|
-R, --recursive | Recursively change ownership of all files and directories within a directory tree |
-H | Follow symbolic links on the command line when used with -R |
-L | Follow all symbolic links when used with -R |
-P | Never follow symbolic links (default behavior with -R) |
-h, --no-dereference | Change the owner of symbolic links themselves, not their targets |
-v, --verbose | Print the name of each file whose ownership changes |
-c, --changes | Like verbose, but only report files that actually change |
--reference=FILE | Change ownership to match the specified reference file instead of using OWNER:GROUP |
-f, --silent, --quiet | Suppress error messages about permission denied and similar errors |
Examples
Change the owner of file.txt to alice, group remains unchanged
chown alice file.txtChange owner to alice and group to staff for file.txt
chown alice:staff file.txtChange only the group to staff, leaving the owner unchanged
chown :staff file.txtRecursively change owner and group of all files in /home/project directory
chown -R alice:staff /home/projectChange the owner of the symlink itself, not its target
chown -h alice symlink.txtChange ownership and report only files that actually changed
chown -c alice file1 file2 file3Change myfile.txt to have the same owner and group as template.txt
chown --reference=template.txt myfile.txtRecursively change all files to UID 1000 and GID 1000 (by numeric ID)
chown -R 1000:1000 /home/newuser