chown - Change file ownership
Synopsis
chown [-R [ -H | -L | -P ]] [ -h ]
owner[:group] file ...
Description
You can use chown to set the owner of
file to the user identifier or profile specified by
owner. Optionally, chown can also set the
group of the file to the group identifier or profile
specified by group.
To change the owner of a file, you must have one of the
following authorities:
- The current user has *ALLOBJ special authority.
- The current user is the owner of the file or directory.
To change the group of a file, you must have one of the
following authorities:
- The current user has *ALLOBJ special authority.
- The current user is the owner of file and either one
of the following:
- The primary group of the job is group.
- One of the supplemental groups of the job is
group.
In addition, the current user must have *USE authority to the
new user profile or group profile.
By default, chown follows symbolic links and
changes the owner and group of the file pointed to by the symbolic
link.
The group of a file cannot be the same as the owner of the file.
Options
- -H
- If the -R option is specified, symbolic links
on the command line are followed. Symbolic links encountered in the
tree traversal are not followed.
- -L
- If the -R option is specified, both symbolic
links on the command line and symbolic links encountered in the
tree traversal are followed.
- -P
- If the -R option is specified, no symbolic
links are followed.
- -R
- If file designates a directory, chown
recursively changes the owner and group of each file in the entire
subtree connected at that point.
- -h
- Change the owner and group of a symbolic link instead of the
file pointed to by the symbolic link.
Operands
The owner operand specifies either a user identifer
number or a user profile name. The group operand specifies
either a group identifier number or a group profile name. The
file operand specifies a path name to an object.
Exit Status
- 0 when successful and all requested changes were made.
- >0 when an error occurred.
Related information
Examples
- Change the owner to user profile "sam" for the file
"personal.file".
chown sam personal.file
- Recursively change the owner to user profile "larry" for the
sub-directory "moe.dir" and all files and sub-directories below
this directory.
chown -R larry moe.dir
- Change the owner to user identifier "500" for the file
"your.file".
chown 500 your.file
- Change the owner to user profile "sam" and the group to group
profile "abbey" for the file "memo.txt".
chown sam:abbey memo.txt