1UMASK(1P) POSIX Programmer's Manual UMASK(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 umask - get or set the file mode creation mask
13
15 umask [-S][mask]
16
18 The umask utility shall set the file mode creation mask of the current
19 shell execution environment (see Shell Execution Environment ) to the
20 value specified by the mask operand. This mask shall affect the initial
21 value of the file permission bits of subsequently created files. If
22 umask is called in a subshell or separate utility execution environ‐
23 ment, such as one of the following:
24
25
26 (umask 002)
27 nohup umask ...
28 find . -exec umask ... \;
29
30 it shall not affect the file mode creation mask of the caller's envi‐
31 ronment.
32
33 If the mask operand is not specified, the umask utility shall write to
34 standard output the value of the invoking process' file mode creation
35 mask.
36
38 The umask utility shall conform to the Base Definitions volume of
39 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
40
41 The following option shall be supported:
42
43 -S Produce symbolic output.
44
45
46 The default output style is unspecified, but shall be recognized on a
47 subsequent invocation of umask on the same system as a mask operand to
48 restore the previous file mode creation mask.
49
51 The following operand shall be supported:
52
53 mask A string specifying the new file mode creation mask. The string
54 is treated in the same way as the mode operand described in the
55 EXTENDED DESCRIPTION section for chmod.
56
57 For a symbolic_mode value, the new value of the file mode creation mask
58 shall be the logical complement of the file permission bits portion of
59 the file mode specified by the symbolic_mode string.
60
61 In a symbolic_mode value, the permissions op characters '+' and '-'
62 shall be interpreted relative to the current file mode creation mask;
63 '+' shall cause the bits for the indicated permissions to be cleared in
64 the mask; '-' shall cause the bits for the indicated permissions to be
65 set in the mask.
66
67 The interpretation of mode values that specify file mode bits other
68 than the file permission bits is unspecified.
69
70 In the octal integer form of mode, the specified bits are set in the
71 file mode creation mask.
72
73 The file mode creation mask shall be set to the resulting numeric
74 value.
75
76 The default output of a prior invocation of umask on the same system
77 with no operand also shall be recognized as a mask operand.
78
79
81 Not used.
82
84 None.
85
87 The following environment variables shall affect the execution of
88 umask:
89
90 LANG Provide a default value for the internationalization variables
91 that are unset or null. (See the Base Definitions volume of
92 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
93 ables for the precedence of internationalization variables used
94 to determine the values of locale categories.)
95
96 LC_ALL If set to a non-empty string value, override the values of all
97 the other internationalization variables.
98
99 LC_CTYPE
100 Determine the locale for the interpretation of sequences of
101 bytes of text data as characters (for example, single-byte as
102 opposed to multi-byte characters in arguments).
103
104 LC_MESSAGES
105 Determine the locale that should be used to affect the format
106 and contents of diagnostic messages written to standard error.
107
108 NLSPATH
109 Determine the location of message catalogs for the processing of
110 LC_MESSAGES .
111
112
114 Default.
115
117 When the mask operand is not specified, the umask utility shall write a
118 message to standard output that can later be used as a umask mask oper‐
119 and.
120
121 If -S is specified, the message shall be in the following format:
122
123
124 "u=%s,g=%s,o=%s\n", <owner permissions>, <group permissions>,
125 <other permissions>
126
127 where the three values shall be combinations of letters from the set {
128 r, w, x}; the presence of a letter shall indicate that the correspond‐
129 ing bit is clear in the file mode creation mask.
130
131 If a mask operand is specified, there shall be no output written to
132 standard output.
133
135 The standard error shall be used only for diagnostic messages.
136
138 None.
139
141 None.
142
144 The following exit values shall be returned:
145
146 0 The file mode creation mask was successfully changed, or no mask
147 operand was supplied.
148
149 >0 An error occurred.
150
151
153 Default.
154
155 The following sections are informative.
156
158 Since umask affects the current shell execution environment, it is gen‐
159 erally provided as a shell regular built-in.
160
161 In contrast to the negative permission logic provided by the file mode
162 creation mask and the octal number form of the mask argument, the sym‐
163 bolic form of the mask argument specifies those permissions that are
164 left alone.
165
167 Either of the commands:
168
169
170 umask a=rx,ug+w
171
172
173 umask 002
174
175 sets the mode mask so that subsequently created files have their
176 S_IWOTH bit cleared.
177
178 After setting the mode mask with either of the above commands, the
179 umask command can be used to write out the current value of the mode
180 mask:
181
182
183 $ umask
184 0002
185
186 (The output format is unspecified, but historical implementations use
187 the octal integer mode format.)
188
189
190 $ umask -S
191 u=rwx,g=rwx,o=rx
192
193 Either of these outputs can be used as the mask operand to a subsequent
194 invocation of the umask utility.
195
196 Assuming the mode mask is set as above, the command:
197
198
199 umask g-w
200
201 sets the mode mask so that subsequently created files have their
202 S_IWGRP and S_IWOTH bits cleared.
203
204 The command:
205
206
207 umask -- -w
208
209 sets the mode mask so that subsequently created files have all their
210 write bits cleared. Note that mask operands -r, -w, -x or anything
211 beginning with a hyphen, must be preceded by "--" to keep it from being
212 interpreted as an option.
213
215 Since umask affects the current shell execution environment, it is gen‐
216 erally provided as a shell regular built-in. If it is called in a sub‐
217 shell or separate utility execution environment, such as one of the
218 following:
219
220
221 (umask 002)
222 nohup umask ...
223 find . -exec umask ... \;
224
225 it does not affect the file mode creation mask of the environment of
226 the caller.
227
228 The description of the historical utility was modified to allow it to
229 use the symbolic modes of chmod. The -s option used in early proposals
230 was changed to -S because -s could be confused with a symbolic_mode
231 form of mask referring to the S_ISUID and S_ISGID bits.
232
233 The default output style is implementation-defined to permit implemen‐
234 tors to provide migration to the new symbolic style at the time most
235 appropriate to their users. A -o flag to force octal mode output was
236 omitted because the octal mode may not be sufficient to specify all of
237 the information that may be present in the file mode creation mask when
238 more secure file access permission checks are implemented.
239
240 It has been suggested that trusted systems developers might appreciate
241 ameliorating the requirement that the mode mask "affects" the file
242 access permissions, since it seems access control lists might replace
243 the mode mask to some degree. The wording has been changed to say that
244 it affects the file permission bits, and it leaves the details of the
245 behavior of how they affect the file access permissions to the descrip‐
246 tion in the System Interfaces volume of IEEE Std 1003.1-2001.
247
249 None.
250
252 Shell Command Language, chmod, the System Interfaces volume of
253 IEEE Std 1003.1-2001, umask()
254
256 Portions of this text are reprinted and reproduced in electronic form
257 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
258 -- Portable Operating System Interface (POSIX), The Open Group Base
259 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
260 Electrical and Electronics Engineers, Inc and The Open Group. In the
261 event of any discrepancy between this version and the original IEEE and
262 The Open Group Standard, the original IEEE and The Open Group Standard
263 is the referee document. The original Standard can be obtained online
264 at http://www.opengroup.org/unix/online.html .
265
266
267
268IEEE/The Open Group 2003 UMASK(1P)