|
|
1.1 ! root 1: .\" Copyright (c) 1980 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)chown.2 6.6 (Berkeley) 5/22/86 ! 6: .\" ! 7: .TH CHOWN 2 "May 22, 1986" ! 8: .UC 4 ! 9: .SH NAME ! 10: chown \- change owner and group of a file ! 11: .SH SYNOPSIS ! 12: .nf ! 13: .ft B ! 14: chown(path, owner, group) ! 15: char *path; ! 16: int owner, group; ! 17: .PP ! 18: .ft B ! 19: fchown(fd, owner, group) ! 20: int fd, owner, group; ! 21: .fi ! 22: .SH DESCRIPTION ! 23: The file ! 24: that is named by \fIpath\fP or referenced by \fIfd\fP ! 25: has its ! 26: .I owner ! 27: and ! 28: .I group ! 29: changed as specified. ! 30: Only the super-user ! 31: may change the owner of the file, ! 32: because if users were able to give files away, ! 33: they could defeat the file-space accounting procedures. ! 34: The owner of the file may change the group ! 35: to a group of which he is a member. ! 36: .PP ! 37: On some systems, ! 38: .I chown ! 39: clears the set-user-id and set-group-id bits ! 40: on the file ! 41: to prevent accidental creation of ! 42: set-user-id and set-group-id programs. ! 43: .PP ! 44: .I Fchown ! 45: is particularly useful when used in conjunction ! 46: with the file locking primitives (see ! 47: .IR flock (2)). ! 48: .PP ! 49: One of the owner or group id's ! 50: may be left unchanged by specifying it as \-1. ! 51: .PP ! 52: If the final component of ! 53: .I path ! 54: is a symbolic link, ! 55: the ownership and group of the symbolic link is changed, ! 56: not the ownership and group of the file or directory to which it points. ! 57: .SH "RETURN VALUE ! 58: Zero is returned if the operation was successful; ! 59: \-1 is returned if an error occurs, with a more specific ! 60: error code being placed in the global variable \fIerrno\fP. ! 61: .SH "ERRORS ! 62: .I Chown ! 63: will fail and the file will be unchanged if: ! 64: .TP 15 ! 65: [ENOTDIR] ! 66: A component of the path prefix is not a directory. ! 67: .TP 15 ! 68: [EINVAL] ! 69: The pathname contains a character with the high-order bit set. ! 70: .TP 15 ! 71: [ENAMETOOLONG] ! 72: A component of a pathname exceeded 255 characters, ! 73: or an entire path name exceeded 1023 characters. ! 74: .TP 15 ! 75: [ENOENT] ! 76: The named file does not exist. ! 77: .TP 15 ! 78: [EACCES] ! 79: Search permission is denied for a component of the path prefix. ! 80: .TP 15 ! 81: [ELOOP] ! 82: Too many symbolic links were encountered in translating the pathname. ! 83: .TP 15 ! 84: [EPERM] ! 85: The effective user ID is not the super-user. ! 86: .TP 15 ! 87: [EROFS] ! 88: The named file resides on a read-only file system. ! 89: .TP 15 ! 90: [EFAULT] ! 91: .I Path ! 92: points outside the process's allocated address space. ! 93: .TP 15 ! 94: [EIO] ! 95: An I/O error occurred while reading from or writing to the file system. ! 96: .PP ! 97: .I Fchown ! 98: will fail if: ! 99: .TP 15 ! 100: [EBADF] ! 101: .I Fd ! 102: does not refer to a valid descriptor. ! 103: .TP 15 ! 104: [EINVAL] ! 105: .I Fd ! 106: refers to a socket, not a file. ! 107: .TP 15 ! 108: [EPERM] ! 109: The effective user ID is not the super-user. ! 110: .TP 15 ! 111: [EROFS] ! 112: The named file resides on a read-only file system. ! 113: .TP 15 ! 114: [EIO] ! 115: An I/O error occurred while reading from or writing to the file system. ! 116: .SH "SEE ALSO" ! 117: chown(8), chgrp(1), chmod(2), flock(2)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.