CHOWN(2) COMMAND REFERENCE CHOWN(2)
NAME
chown, fchown - 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
may execute this call, because if users were able to give
files away, they could defeat the file-space accounting
procedures.
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.
Fchown is particularly useful when used in conjunction with
the file locking primitives (see flock(2)).
Only one of owner and group may be set by specifying the
other as -1.
DIAGNOSTICS
Chown will fail and the file will be unchanged if:
[ENOTDIR]
A component of the path prefix is not a directory.
[ENAMETOOLONG]
The argument pathname is too long.
[ENOASCII]
The argument path contains a byte with the high-order
bit set.
[ENOENT]
The named file does not exist.
[EPERM]
The effective user ID is not the super-user.
[EROFS]
The named file resides on a read-only file system.
[EFAULT]
Printed 10/17/86 1
CHOWN(2) COMMAND REFERENCE CHOWN(2)
Path points outside the process's allocated address
space.
[EPERM]
The effective user ID is not the super-user.
[ELOOP]
Too many symbolic links were encountered in translating
the pathname.
[EIO]
An I/O error occurred while reading from or writing to
the file system.
[EDFSNOSUCHHOST]
The pathname referenced a remote host, but when we
broadcast a request for its address, no host responded.
Fchown will fail if:
[EBADF]
Fd does not refer to a valid descriptor.
[EPERM]
The effective user ID is not the super-user.
[EROFS]
The named file resides on a read-only file system.
[EIO]
An I/O error occurred while reading from or writing to
the file system.
[EINVAL]
Fd refers to a socket, not a file.
RETURN VALUE
Upon successful completion, a value of 0 is returned.
Otherwise, a value of -1 is returned and errno is set to
indicate the error.
SEE ALSO
chmod(2), flock(2).
Printed 10/17/86 2
%%index%%
na:72,84;
sy:156,715;
de:871,873;
di:1744,623;2511,944;
rv:3455,236;
se:3691,109;
%%index%%000000000115