chown(2P) INTERACTIVE UNIX System (POSIX) chown(2P)
NAME
chown - change owner and group of a file
SYNOPSIS
#include <sys/types.h>
int chown (path, owner, group)
char *path;
uid_t owner;
gid_t 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 processes with effective user ID equal to the file
owner or superuser may change the ownership of a file.
Changing the owner is restricted to processes with appropri-
ate privileges. Changing the group is permitted to a pro-
cess without appropriate privileges, but with an effective
user ID equal to the user ID of the file, if and only if
owner is equal to the file's user ID and group is equal to
either the calling process's effective group ID or one of
its supplementary groups.
If chown 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.
chown will fail and the owner and group of the named file
will remain unchanged if one or more of the following is
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 superuser.
[EROFS] The named file resides on a read-only file
system.
[EFAULT] The path variable points outside the allo-
cated address space of the process.
Rev. 1.1 Page 1
chown(2P) INTERACTIVE UNIX System (POSIX) chown(2P)
[EINTR] A signal was caught during the chown system
call.
[ENOLINK] The variable path points to a remote machine
and the link to that machine is no longer
active.
[EMULTIHOP] Components of path require hopping to multi-
ple remote machines.
[ENAMETOOLONG] The length of the path argument exceeds
{PATH_MAX}, or a path name component is
longer than {NAME_MAX} while
{_POSIX_NO_TRUNC} is in effect.
SEE ALSO
chmod(2P).
chown(1) in the INTERACTIVE UNIX System User's/System
Administrator's Reference Manual.
DIAGNOSTICS
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned, and errno is set to indi-
cate the error.
Rev. 1.1 Page 2