chown(1) chown(1)
chown, chgrp - change owner or group
chown [ -Rfh ] owner[{.|:}group] file ...
chgrp [ -Rfh ] group file ...
chown changes the owner of the files to owner. The owner may be either a
login name found in the password file, or a decimal user ID. An optional
group, separated from the owner by either a period or a colon, may also
be specified. The group may be either a group name found in the group
file, or a decimal group ID.
chgrp changes the group ID of the files to group. The group may be
either a group name found in the group file, or a decimal group ID.
No errors, except for usage errors, are reported when the -f (force)
option is given.
When the -R option is given, the command recursively descends its
directory arguments setting the specified owner or group. When symbolic
links are encountered and the -h option is not given, they are traversed
and the owner/group of the file referenced by the symbolic link is
changed.
When the -h option is given and the file is a symbolic link, change the
owner/group of the symbolic link. Without this option, the owner/group
of the file referenced by the symbolic link is changed.
If either command is invoked by other than the superuser, the set-user-ID
and set-group-ID bits of the file mode, 04000 and 02000 respectively,
will be cleared.
Only the owner of a file (or the superuser) may change the owner or group
of that file.
However, if the variable restricted_chown is enabled (see intro(2) and
systune(1M)) then only the superuser can change the owner of the file,
because if users were able to give files away, they could defeat the file
space accounting procedures. The owner of the file may change the group
ownership only to those groups of which he is a member.
/etc/passwd
/etc/group
Because chown uses a depth-first algorithm to recursively descend its
directory arguments, there is a limitation to how deep it can descend
which is dependent on the number of file descriptors available to a given
Page 1
chown(1) chown(1)
shell. find(1) can be used if one needs to descend deeper than a given
configuration will allow.
chmod(1), find(1), chown(2), group(4), passwd(4), stat(4).
chown and chgrp will exit with a status of 0 if all file operations
completed successfully. If there are any failures, the exit status will
be > 0.
PPPPaaaaggggeeee 2222 [ Back ]
|