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. The chown command 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 superuser. The fchown command 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. Normally only the superuser may execute this call, because if users were able to give files away, they could defeat the file-space accounting procedures. The exception to this is when owner is -1 and group is in the current group access list of the calling process; this lets any user change the group of a file they own as long as they're a member of that group. DIAGNOSTICS The chown command fails and the file remains unchanged if: [ENOTDIR] A component of the path prefix is not a directory. [ENAMETOOLONG] The argument path name 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 superuser and this call would change the file's ownership, or would change the file's group to one of which the process is not a member. [EROFS] The named file resides on a read-only file Printed 4/6/89 1
CHOWN(2) COMMAND REFERENCE CHOWN(2) system. [EFAULT] The path argument points outside the process's allocated address space. [ELOOP] Too many symbolic links were encountered in translating the path name. [EIO] An I/O error occurred while reading from or writing to the file system. The fchown command fails if: [EBADF] The fd argument does not refer to a valid descriptor. [EPERM] The effective user ID is not the superuser and this call would change the file's ownership, or would change the file's group to one of which the process is not a member. [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] The fd argument 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), and getgroups(2). Printed 4/6/89 2
%%index%% na:264,100; sy:364,1099; de:1463,1202; di:2665,872;3873,1118; rv:4991,280; se:5271,181; %%index%%000000000121