.\" 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.6 (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
may 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
to a group of which he is a member.
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
One of the owner or group id's
may be left unchanged by specifying it as \-1.
If the final component of
the ownership and group of the symbolic link is changed,
not the ownership and group of the file or directory to which it points.
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 is not the super-user.
The named file resides on a read-only file system.
points outside the process's allocated address space.
An I/O error occurred while reading from or writing to the file system.
does not refer to a valid descriptor.
refers to a socket, not a file.
The effective user ID is not the super-user.
The named file resides on a read-only file system.
An I/O error occurred while reading from or writing to the file system.
chown(8), chgrp(1), chmod(2), flock(2)