CHOWN(2) CHOWN(2)
NAME
chown - change owner and group of a file
SYNOPSIS
int chown (path, owner, group)
char *path;
int owner, group;
DESCRIPTION
Path points to a path name naming a file. The owner ID and
group ID of the named file are set to the numeric values
contained in owner and group respectively.
Only the owner of a file (or the super-user) may change the
owner or group of that file. If POSIXCHOWNRESTRICTED is
in effect (system configuration option, off by default),
only the super-user may change the owner of the file, and,
to change the group, a user must belong to the specified
group and be the owner of the file (or be the super-user).
If chown is invoked by other than the super-user, the set-
user-ID and set-group-ID bits of the file mode, 04000 and
02000 respectively, will be cleared.
chown will fail and the owner and group of the named file
will remain unchanged if one or more of the following are
true:
[ENOTDIR] A component of the path prefix is not a
directory.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied on a component of
the path prefix.
[EPERM] The effective user ID does not match the
owner of the file and the effective user ID
is not super-user. If POSIXCHOWNRESTRICTED
is in effect, then the effective user ID is
Page 1 May 1989
CHOWN(2) CHOWN(2)
not super-user.
[EROFS] The named file resides on a read-only file
system.
[EFAULT] Path points outside the allocated address
space of the process.
[EINTR] A signal was caught during the chown system
call.
[ENOLINK] Path points to a remote machine and the link
to that machine is no longer active.
[EMULTIHOP] Components of path require hopping to
multiple remote machines.
SEE ALSO
chmod(2).
chown(1) in the User's Reference Manual.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned.
Otherwise, a value of -1 is returned and errno is set to
indicate the error.
Page 2 May 1989