chown — Change the owner or group of a file or directory
:group] pathname ...Purpose
chown sets the user ID (UID) to owner for the files and directories named by pathname arguments. owner can be a user name from the user profile, or it can be a numeric user ID.
If you include a group name—that is, if you specify
owner followed immediately by a colon (:) and then
group with no intervening spaces, such as
owner:group—chown also sets the group ID
to group for the files and directories named.
Options
- –f
- Does not issue an error message if chown cannot change the owner. In this case, chown always returns a status of zero. Other errors may cause a nonzero return status.
- –R
- If pathname on the command line is the name of a directory, chown changes all the files and subdirectories in that directory to belong to the specified owner (and group, if :group is specified). If chown cannot change some file or subdirectory in the directory, it continues to try to change the other files and subdirectories in the directory, but exits with a nonzero status.
Localization
- LANG
- LC_ALL
- LC_CTYPE
- LC_MESSAGES
Usage Notes
For a mounted external link, both the linked object and the link itself have an owner and group ID. However, true ownership of the external link rests with the linked object. Specifying the chown command with the name of the external link changes only the owner or group ID of the link. To change the owner or group ID of the linked object, specify the name of the external link with a closing slash (/) or specify its fully qualified pathname.
Exit Values
0- You specified –f, or chown successfully changed the ownership of all the specified files and directories.
1- Failure due to any of the following:
- Inability to access a specified file.
- Inability to change the owner of a specified file.
- Inability to read the directory containing the directory entry of the file.
- An irrecoverable error was encountered when using the –R option.
2- Failure due to any of the following:
- The command line contained an incorrect option.
- The command line had too few arguments.
- An owner was specified with a user ID that the system did not recognize.
Portability
POSIX.2, UNIX systems. The –f option is an extension of the POSIX standard.
Related Commands
chgrp, chmod