chown(2) chown(2)
NAME
chown - change owner and group of a file
SYNOPSIS
chown(path, owner, group)
char *path;
int owner, group;
fchown(fd, owner, group)
int fd, owner, group;
DESCRIPTION
The file which is named by path or referenced by fd has its
owner and group changed as specified. Only the super-user
or the file's owner may execute this call.
On some systems, chown clears the set-user-ID and set-
group-id bits on the file to prevent accidental creation of
set-user-ID and set-group-ID programs owned by the super-
user.
Only one of the owner and group ID's may be set by
specifying the other as -1.
RETURN VALUE
Zero is returned if the operation was successful; -1 is
returned if an error occurs, with a more specific error code
being placed in the global variable errno.
ERRORS
chown will fail and the file will be unchanged if:
[EINVAL] The argument path does not refer to a file.
[ENOTDIR] A component of the path prefix is not a
directory.
[ENOENT] The argument pathname is too long.
[EPERM] The argument contains a byte with the high-
order bit set.
[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 the super-user.
[EROFS] The named file resides on a read-only file
Page 1 (last mod. 1/14/87)
chown(2) chown(2)
system.
[EFAULT] path points outside the process's allocated
address space.
[ELOOP] Too many symbolic links were encountered in
translating the pathname.
fchown will fail if:
[EBADF]
fd does not refer to a valid descriptor.
[EINVAL]
fd refers to a socket, not a file.
SEE ALSO
chmod(2).
Page 2 (last mod. 1/14/87)