1umask(1) User Commands umask(1)
2
3
4
6 umask - get or set the file mode creation mask
7
9 /usr/bin/umask [-S] [mask]
10
11
12 sh
13 umask [ooo]
14
15
16 csh
17 umask [ooo]
18
19
20 ksh
21 umask [-S] [mask]
22
23
24 ksh93
25 umask [-S] [mask]
26
27
29 The umask utility sets the file mode creation mask of the current shell
30 execution environment to the value specified by the mask operand. This
31 mask affects the initial value of the file permission bits of subse‐
32 quently created files. If umask is called in a subshell or separate
33 utility execution environment, such as one of the following:
34
35 (umask 002)
36 nohup umask ...
37 find . -exec umask ...
38
39
40
41
42 it does not affect the file mode creation mask of the caller's environ‐
43 ment. For this reason, the /usr/bin/umask utility cannot be used to
44 change the umask in an ongoing session. Its usefulness is limited to
45 checking the caller's umask. To change the umask of an ongoing session
46 you must use one of the shell builtins.
47
48
49 If the mask operand is not specified, the umask utility writes the
50 value of the invoking process's file mode creation mask to standard
51 output.
52
53 sh
54 The user file-creation mode mask is set to ooo. The three octal digits
55 refer to read/write/execute permissions for owner, group, and other,
56 respectively (see chmod(1), chmod(2), and umask(2)). The value of each
57 specified digit is subtracted from the corresponding ``digit'' speci‐
58 fied by the system for the creation of a file (see creat(2)). For exam‐
59 ple, umask 022 removes write permission for group and other. Files (and
60 directories) normally created with mode 777 become mode 755. Files (and
61 directories) created with mode 666 become mode 644).
62
63 o If ooo is omitted, the current value of the mask is printed.
64
65 o umask is recognized and executed by the shell.
66
67 o umask can be included in the user's .profile (see pro‐
68 file(4)) and invoked at login to automatically set the
69 user's permissions on files or directories created.
70
71 csh
72 See the description above for the Bourne shell (sh)umask built-in.
73
74 ksh
75 The user file-creation mask is set to mask. mask can either be an octal
76 number or a symbolic value as described in chmod(1). If a symbolic
77 value is given, the new umask value is the complement of the result of
78 applying mask to the complement of the previous umask value. If mask is
79 omitted, the current value of the mask is printed.
80
81 ksh93
82 umask sets the file creation mask of the current shell execution envi‐
83 ronment to the value specified by the mask operand. This mask affects
84 the file permission bits of subsequently created files. mask can either
85 be an octal number or a symbolic value as described in chmod(1). If a
86 symbolic value is specified, the new file creation mask is the comple‐
87 ment of the result of applying mask to the complement of the current
88 file creation mask. If mask is not specified, umask writes the value of
89 the file creation mask for the current process to standard output.
90
92 ksh
93 The following option is supported for /usr/bin/umask and umask in ksh:
94
95 -S Produces symbolic output.
96
97
98
99 The default output style is unspecified, but will be recognized on a
100 subsequent invocation of umask on the same system as a mask operand to
101 restore the previous file mode creation mask.
102
103 ksh93
104 The following option is supported in ksh93:
105
106 -S Causes the file creation mask to be written or treated as a sym‐
107 bolic value rather than an octal number.
108
109
111 The following operand is supported:
112
113 mask A string specifying the new file mode creation mask. The string
114 is treated in the same way as the mode operand described in the
115 chmod(1) manual page.
116
117 For a symbolic_mode value, the new value of the file mode cre‐
118 ation mask is the logical complement of the file permission
119 bits portion of the file mode specified by the symbolic_mode
120 string.
121
122 In a symbolic_mode value, the permissions op characters + and −
123 are interpreted relative to the current file mode creation
124 mask. + causes the bits for the indicated permissions to be
125 cleared in the mask. − causes the bits of the indicated permis‐
126 sions to be set in the mask.
127
128 The interpretation of mode values that specify file mode bits
129 other than the file permission bits is unspecified.
130
131 The file mode creation mask is set to the resulting numeric
132 value.
133
134 The default output of a prior invocation of umask on the same
135 system with no operand will also be recognized as a mask oper‐
136 and. The use of an operand obtained in this way is not obsoles‐
137 cent, even if it is an octal number.
138
139
141 When the mask operand is not specified, the umask utility will write a
142 message to standard output that can later be used as a umask mask oper‐
143 and.
144
145
146 If -S is specified, the message will be in the following format:
147
148 "u=%s,g=%s,o=%s\n", owner permissions, group permissions, \
149 other permissions
150
151
152
153
154 where the three values will be combinations of letters from the set {r,
155 w, x}. The presence of a letter will indicate that the corresponding
156 bit is clear in the file mode creation mask.
157
158
159 If a mask operand is specified, there will be no output written to
160 standard output.
161
163 Example 1 Using the umask Command
164
165
166 The examples in this section refer to the /usr/bin/umask utility and
167 the ksh umask builtin.
168
169
170
171 Either of the commands:
172
173
174 umask a=rx,ug+w
175 umask 002
176
177
178
179
180 sets the mode mask so that subsequently created files have their
181 S_IWOTH bit cleared.
182
183
184
185 After setting the mode mask with either of the above commands, the
186 umask command can be used to write the current value of the mode mask:
187
188
189 example$ umask
190 0002
191
192
193
194
195 The output format is unspecified, but historical implementations use
196 the obsolescent octal integer mode format.
197
198
199 example$ umask -S
200 u=rwx,g=rwx,o=rx
201
202
203
204
205 Either of these outputs can be used as the mask operand to a subsequent
206 invocation of the umask utility.
207
208
209
210 Assuming the mode mask is set as above, the command:
211
212
213 umask g-w
214
215
216
217
218 sets the mode mask so that subsequently created files have their
219 S_IWGRP and S_IWOTH bits cleared.
220
221
222
223 The command:
224
225
226 umask --w
227
228
229
230
231 sets the mode mask so that subsequently created files have all their
232 write bits cleared. Notice that mask operands r, w, x, or anything
233 beginning with a hyphen (−), must be preceded by - to keep it from
234 being interpreted as an option.
235
236
238 See environ(5) for descriptions of the following environment variables
239 that affect the execution of umask: LANG, LC_ALL, LC_COLLATELC_CTYPE,
240 LC_MESSAGES, and NLSPATH.
241
243 The following exit values are returned:
244
245 0 The file mode creation mask was successfully changed, or no mask
246 operand was supplied.
247
248
249 >0 An error occurred.
250
251
253 See attributes(5) for descriptions of the following attributes:
254
255 /usr/bin/umask, csh, ksh, sh
256 ┌─────────────────────────────┬─────────────────────────────┐
257 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
258 ├─────────────────────────────┼─────────────────────────────┤
259 │Availability │SUNWcsu │
260 ├─────────────────────────────┼─────────────────────────────┤
261 │Interface Stability │Standard │
262 └─────────────────────────────┴─────────────────────────────┘
263
264 ksh93
265 ┌─────────────────────────────┬─────────────────────────────┐
266 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
267 ├─────────────────────────────┼─────────────────────────────┤
268 │Availability │SUNWcsu │
269 ├─────────────────────────────┼─────────────────────────────┤
270 │Interface Stability │External │
271 └─────────────────────────────┴─────────────────────────────┘
272
274 chmod(1), csh(1), ksh(1), ksh93(1), sh(1), chmod(2), creat(2),
275 umask(2), profile(4), attributes(5), environ(5), standards(5)
276
277
278
279SunOS 5.11 17 Sep 2007 umask(1)