BSD 4_4_Lite2 development
[unix-history] / usr / share / man / cat1 / chmod.0
CommitLineData
32424d04
C
1CHMOD(1) BSD Reference Manual CHMOD(1)
2
3N\bNA\bAM\bME\bE
4 c\bch\bhm\bmo\bod\bd - change file modes
5
6S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
7 c\bch\bhm\bmo\bod\bd [-\b-R\bR [-\b-H\bH | -\b-L\bL | -\b-P\bP]] _\bm_\bo_\bd_\be _\bf_\bi_\bl_\be _\b._\b._\b.
8
9D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
10 The c\bch\bhm\bmo\bod\bd utility modifies the file mode bits of the listed files as
11 specified by the _\bm_\bo_\bd_\be operand.
12
13 The options are as follows:
14
15 -\b-H\bH If the -\b-R\bR option is specified, symbolic links on the command line
16 are followed. (Symbolic links encountered in the tree traversal
17 are not followed.)
18
19 -\b-L\bL If the -\b-R\bR option is specified, all symbolic links are followed.
20
21 -\b-P\bP If the -\b-R\bR option is specified, no symbolic links are followed.
22
23 -\b-R\bR Change the modes of the file hierarchies rooted in the files in-
24 stead of just the files themselves.
25
26 Symbolic links do not have modes, so unless the -\b-H\bH or -\b-L\bL option is set,
27 c\bch\bhm\bmo\bod\bd on a symbolic link always succeeds and has no effect. The -\b-H\bH, -\b-L\bL
28 and -\b-P\bP options are ignored unless the -\b-R\bR option is specified. In addi-
29 tion, these options override each other and the command's actions are de-
30 termined by the last one specified.
31
32 Only the owner of a file or the super-user is permitted to change the
33 mode of a file.
34
35 The c\bch\bhm\bmo\bod\bd utility exits 0 on success, and >0 if an error occurs.
36
37M\bMO\bOD\bDE\bES\bS
38 Modes may be absolute or symbolic. An absolute mode is an octal number
39 constructed by _\bo_\br_\b-_\bi_\bn_\bg the following values:
40
41 4000 set-user-ID-on-execution
42 2000 set-group-ID-on-execution
43 1000 sticky bit, see chmod(2)
44 0400 read by owner
45 0200 write by owner
46 0100 execute (or search for directories) by owner
47 0070 read, write, execute/search by group
48 0007 read, write, execute/search by others
49
50 The read, write, and execute/search values for group and others are en-
51 coded as described for owner.
52
53 The symbolic mode is described by the following grammar:
54
55 mode ::= clause [, clause ...]
56 clause ::= [who ...] [action ...] last_action
57 action ::= op [perm ...]
58 last_action ::= op [perm ...]
59 who ::= a | u | g | o
60 op ::= + | - | =
61 perm ::= r | s | t | w | x | X | u | g | o
62
63 The _\bw_\bh_\bo symbols ``u'', ``g'', and ``o'' specify the user, group, and oth-
64 er parts of the mode bits, respectively. The _\bw_\bh_\bo symbol ``a'' is equiva-
65 lent to ``ugo''.
66
67 The _\bp_\be_\br_\bm symbols represent the portions of the mode bits as follows:
68
69 r The read bits.
70 s The set-user-ID-on-execution and set-group-ID-on-execution
71 bits.
72 t The sticky bit.
73 w The write bits.
74 x The execute/search bits.
75 X The execute/search bits if the file is a directory or any
76 of the execute/search bits are set in the original (unmodi-
77 fied) mode. Operations with the _\bp_\be_\br_\bm symbol ``X'' are only
78 meaningful in conjunction with the _\bo_\bp symbol ``+'', and are
79 ignored in all other cases.
80 u The user permission bits in the mode of the original file.
81 g The group permission bits in the mode of the original file.
82 o The other permission bits in the mode of the original file.
83
84 The _\bo_\bp symbols represent the operation performed, as follows:
85
86 + If no value is supplied for _\bp_\be_\br_\bm, the ``+'' operation has no ef-
87 fect. If no value is supplied for _\bw_\bh_\bo, each permission bit speci-
88 fied in _\bp_\be_\br_\bm, for which the corresponding bit in the file mode cre-
89 ation mask is clear, is set. Otherwise, the mode bits represented
90 by the specified _\bw_\bh_\bo and _\bp_\be_\br_\bm values are set.
91
92 - If no value is supplied for _\bp_\be_\br_\bm, the ``-'' operation has no ef-
93 fect. If no value is supplied for _\bw_\bh_\bo, each permission bit speci-
94 fied in _\bp_\be_\br_\bm, for which the corresponding bit in the file mode cre-
95 ation mask is clear, is cleared. Otherwise, the mode bits repre-
96 sented by the specified _\bw_\bh_\bo and _\bp_\be_\br_\bm values are cleared.
97
98 = The mode bits specified by the _\bw_\bh_\bo value are cleared, or, if no who
99 value is specified, the owner, group and other mode bits are
100 cleared. Then, if no value is supplied for _\bw_\bh_\bo, each permission
101 bit specified in _\bp_\be_\br_\bm, for which the corresponding bit in the file
102 mode creation mask is clear, is set. Otherwise, the mode bits rep-
103 resented by the specified _\bw_\bh_\bo and _\bp_\be_\br_\bm values are set.
104
105 Each _\bc_\bl_\ba_\bu_\bs_\be specifies one or more operations to be performed on the mode
106 bits, and each operation is applied to the mode bits in the order speci-
107 fied.
108
109 Operations upon the other permissions only (specified by the symbol ``o''
110 by itself), in combination with the _\bp_\be_\br_\bm symbols ``s'' or ``t'', are ig-
111 nored.
112
113E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS
114 644 make a file readable by anyone and writable by the owner
115 only.
116
117 go-w deny write permission to group and others.
118
119 =rw,+X set the read and write permissions to the usual defaults,
120 but retain any execute permissions that are currently set.
121
122 +X make a directory or file searchable/executable by everyone
123 if it is already searchable/executable by anyone.
124
125 755
126 u=rwx,go=rx
127 u=rwx,go=u-w make a file readable/executable by everyone and writable by
128 the owner only.
129
130
131
132 go= clear all mode bits for group and others.
133
134 g=u-w set the group bits equal to the user bits, but clear the
135 group write bit.
136
137B\bBU\bUG\bGS\bS
138 There's no _\bp_\be_\br_\bm option for the naughty bits.
139
140S\bSE\bEE\bE A\bAL\bLS\bSO\bO
141 install(1), chmod(2), stat(2), umask(2), fts(3), setmode(3),
142 symlink(7), chown(8)
143
144S\bST\bTA\bAN\bND\bDA\bAR\bRD\bDS\bS
145 The c\bch\bhm\bmo\bod\bd utility is expected to be POSIX 1003.2 compatible with the ex-
146 ception of the _\bp_\be_\br_\bm symbols ``t'' and ``X'' which are not included in
147 that standard.
148
1494.4BSD March 31, 1994 3