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