chown - change the file ownership
chown [-R] owner[:group] file ...
The chown utility will set the user ID of the file named by each file operand to the user ID specified by the owner operand.For each file operand, it will perform actions equivalent to the XSH specification chown() function, called with the following arguments:
- The file operand will be used as the path argument.
- The user ID indicated by the owner portion of the first operand will be used as the owner argument.
- If the group portion of the first operand is given, the group ID indicated by it will be used as the group argument; otherwise, the group ID of the file will be used as the group argument.
Unless chown is invoked by a process with appropriate privileges, the set-user-ID and set-group-ID bits of a regular file will be cleared upon successful completion; the set-user-ID and set-group-ID bits of other file types may be cleared.
The chown utility supports the XBD specification, Utility Syntax Guidelines .The following option is supported:
- -R
- Recursively change file user IDs, and if the group operand is specified, group IDs. For each file operand that names a directory, chown changes the user and group ID of the directory and all files in the file hierarchy below it.
The following operands are supported:
- owner[:group]
- A user ID and optional group ID to be assigned to file. The owner portion of this operand must be a user name from the user database or a numeric user ID. Either specifies a user ID to be given to each file named by one of the file operands. If a numeric owner operand exists in the user database as a user name, the user ID number associated with that user name will be used as the user ID. Similarly, if the group portion of this operand is present, it must be a group name from the group database or a numeric group ID. Either specifies a group ID to be given to each file. If a numeric group operand exists in the group database as a group name, the group ID number associated with that group name will be used as the group ID.
- file
- A pathname of a file whose user ID is to be modified.
Not used.
None.
The following environment variables affect the execution of chown:
- LANG
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- LC_CTYPE
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
- LC_MESSAGES
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- NLSPATH
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Default.
Not used.
Used only for diagnostic messages.
None.
None.
The following exit values are returned:
- 0
- The utility executed successfully and all requested changes were made.
- >0
- An error occurred.
If, when invoked with the -R option, chown attempts but fails to change the user ID or, if the group operand is specified, group ID, of a particular file in a specified file hierarchy, it will continue to process the remaining files in the hierarchy.If chown cannot read or search a directory within a hierarchy, it will continue to process the other parts of the hierarchy that are accessible.
Only the owner of a file or the user with appropriate privileges may change the owner or group of a file.Some systems restrict the use of chown to a user with appropriate privileges.
None.
None.
chmod, chgrp, the XSH specification description of chown().