.\" Copyright (c) 1980 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\" @(#)chown.2 6.3 (Berkeley) %G%
chown \- change owner and group of a file
chown(path, owner, group)
that is named by \fIpath\fP or referenced by \fIfd\fP
because if users were able to give files away,
they could defeat the file-space accounting procedures.
clears the set-user-id and set-group-id bits
to prevent accidental creation of
set-user-id and set-group-id programs
is particularly useful when used in conjunction
with the file locking primitives (see
Only one of the owner and group id's
may be set by specifying the other as \-1.
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 \fIerrno\fP.
will fail and the file will be unchanged if:
A component of the path prefix is not a directory.
The pathname contains a character with the high-order bit set.
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
The named file does not exist.
Search permission is denied for a component of the path prefix.
Too many symbolic links were encountered in translating the pathname.
The effective user ID does not match the owner of the file and
the effective user ID is not the super-user.
The named file resides on a read-only file system.
points outside the process's allocated address space.
does not refer to a valid descriptor.
refers to a socket, not a file.
The named file resides on a read-only file system.