manual page distributed with 4.1BSD
[unix-history] / usr / src / lib / libc / sys / chmod.2
CommitLineData
d149e2aa
KM
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.\" @(#)chmod.2 4.1 (Berkeley) %G%
6.\"
7.TH CHMOD 2
8.UC 4
9.SH NAME
10chmod \- change mode of file
11.SH SYNOPSIS
12.nf
13.B chmod(name, mode)
14.B char *name;
15.fi
16.SH DESCRIPTION
17The file whose name
18is given as the null-terminated string pointed to by
19.I name
20has its mode changed to
21.IR mode .
22Modes are constructed by
23.IR or ing
24together some
25combination of the following:
26.PP
27.RS
28 04000 set user ID on execution
29 02000 set group ID on execution
30 01000 save text image after execution
31 00400 read by owner
32 00200 write by owner
33 00100 execute (search on directory) by owner
34 00070 read, write, execute (search) by group
35 00007 read, write, execute (search) by others
36.RE
37.PP
38If an executable file is set up for sharing (this is the default)
39then mode 1000 prevents the system from
40abandoning the swap-space image of the program-text portion
41of the file when its last user
42terminates.
43Ability to set this bit is restricted to the super-user
44since swap space is consumed
45by the images.
46See
47.IR sticky (8).
48.PP
49Only the owner of a file (or the super-user) may change the mode.
50Only the super-user can set the 1000 mode.
51.PP
52On some systems,
53writing or changing the owner of a file
54turns off the set-user-id bit.
55This makes the system somewhat more secure
56by protecting set-user-id files
57from remaining set-user-id if they are modified,
58at the expense of a degree of compatibility.
59.SH "SEE ALSO"
60chmod(1)
61.SH DIAGNOSTIC
62Zero is returned if the mode is changed;
63\-1 is returned if
64.I name
65cannot be found or if the current user
66is neither the owner of the file nor the super-user.
67.SH "ASSEMBLER (PDP-11)"
68(chmod = 15.)
69.br
70.B sys chmod; name; mode