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 | int chown(const char *\fIpath\fP, int \fIowner\fP, int \fIgroup\fP)
|
---|
15 | .ig \" You never know
|
---|
16 | .PP
|
---|
17 | .ft B
|
---|
18 | int fchown(int \fIfd\fP, int \fIowner\fP, int \fIgroup\fP)
|
---|
19 | ..
|
---|
20 | .fi
|
---|
21 | .SH DESCRIPTION
|
---|
22 | The file
|
---|
23 | that is named by \fIpath\fP
|
---|
24 | .ig
|
---|
25 | or referenced by \fIfd\fP
|
---|
26 | ..
|
---|
27 | has its
|
---|
28 | .I owner
|
---|
29 | and
|
---|
30 | .I group
|
---|
31 | changed as specified.
|
---|
32 | Only the super-user
|
---|
33 | may change the owner of the file,
|
---|
34 | because if users were able to give files away,
|
---|
35 | they could defeat file-space accounting procedures.
|
---|
36 | The owner of the file may change the group
|
---|
37 | to a group of which he is a member.
|
---|
38 | .PP
|
---|
39 | On some systems,
|
---|
40 | .I chown
|
---|
41 | clears the set-user-id and set-group-id bits
|
---|
42 | on the file
|
---|
43 | to prevent accidental creation of
|
---|
44 | set-user-id and set-group-id programs.
|
---|
45 | .SH "RETURN VALUE
|
---|
46 | Zero is returned if the operation was successful;
|
---|
47 | \-1 is returned if an error occurs, with a more specific
|
---|
48 | error code being placed in the global variable \fBerrno\fP.
|
---|
49 | .SH "ERRORS
|
---|
50 | .B Chown
|
---|
51 | will fail and the file will be unchanged if:
|
---|
52 | .TP 15
|
---|
53 | [ENOTDIR]
|
---|
54 | A component of the path prefix is not a directory.
|
---|
55 | .TP 15
|
---|
56 | [ENAMETOOLONG]
|
---|
57 | The path name exceeds PATH_MAX characters.
|
---|
58 | .TP 15
|
---|
59 | [ENOENT]
|
---|
60 | The named file does not exist.
|
---|
61 | .TP 15
|
---|
62 | [EACCES]
|
---|
63 | Search permission is denied for a component of the path prefix.
|
---|
64 | .TP 15
|
---|
65 | [ELOOP]
|
---|
66 | Too many symbolic links were encountered in translating the pathname.
|
---|
67 | (Minix-vmd)
|
---|
68 | .TP 15
|
---|
69 | [EPERM]
|
---|
70 | The effective user ID is not the super-user.
|
---|
71 | .TP 15
|
---|
72 | [EROFS]
|
---|
73 | The named file resides on a read-only file system.
|
---|
74 | .TP 15
|
---|
75 | [EFAULT]
|
---|
76 | .I Path
|
---|
77 | points outside the process's allocated address space.
|
---|
78 | .TP 15
|
---|
79 | [EIO]
|
---|
80 | An I/O error occurred while reading from or writing to the file system.
|
---|
81 | .ig
|
---|
82 | .PP
|
---|
83 | .B Fchown
|
---|
84 | will fail if:
|
---|
85 | .TP 15
|
---|
86 | [EBADF]
|
---|
87 | .I Fd
|
---|
88 | does not refer to a valid descriptor.
|
---|
89 | .TP 15
|
---|
90 | [EPERM]
|
---|
91 | The effective user ID is not the super-user.
|
---|
92 | .TP 15
|
---|
93 | [EROFS]
|
---|
94 | The named file resides on a read-only file system.
|
---|
95 | .TP 15
|
---|
96 | [EIO]
|
---|
97 | An I/O error occurred while reading from or writing to the file system.
|
---|
98 | ..
|
---|
99 | .SH "SEE ALSO"
|
---|
100 | .BR chown (8),
|
---|
101 | .BR chgrp (1),
|
---|
102 | .BR chmod (2).
|
---|