1UMASK(P)                   POSIX Programmer's Manual                  UMASK(P)
2
3
4

NAME

6       umask - get or set the file mode creation mask
7

SYNOPSIS

9       umask [-S][mask]
10

DESCRIPTION

12       The  umask utility shall set the file mode creation mask of the current
13       shell execution environment (see Shell Execution Environment )  to  the
14       value specified by the mask operand. This mask shall affect the initial
15       value of the file permission bits of  subsequently  created  files.  If
16       umask  is  called  in a subshell or separate utility execution environ‐
17       ment, such as one of the following:
18
19
20              (umask 002)
21              nohup umask ...
22              find . -exec umask ... \;
23
24       it shall not affect the file mode creation mask of the  caller's  envi‐
25       ronment.
26
27       If  the mask operand is not specified, the umask utility shall write to
28       standard output the value of the invoking process' file  mode  creation
29       mask.
30

OPTIONS

32       The  umask  utility  shall  conform  to  the Base Definitions volume of
33       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
34
35       The following option shall be supported:
36
37       -S     Produce symbolic output.
38
39
40       The default output style is unspecified, but shall be recognized  on  a
41       subsequent  invocation of umask on the same system as a mask operand to
42       restore the previous file mode creation mask.
43

OPERANDS

45       The following operand shall be supported:
46
47       mask   A string specifying the new file mode creation mask. The  string
48              is  treated in the same way as the mode operand described in the
49              EXTENDED DESCRIPTION section for chmod.
50
51       For a symbolic_mode value, the new value of the file mode creation mask
52       shall  be the logical complement of the file permission bits portion of
53       the file mode specified by the symbolic_mode string.
54
55       In a symbolic_mode value, the permissions op  characters  '+'  and  '-'
56       shall  be  interpreted relative to the current file mode creation mask;
57       '+' shall cause the bits for the indicated permissions to be cleared in
58       the  mask; '-' shall cause the bits for the indicated permissions to be
59       set in the mask.
60
61       The interpretation of mode values that specify  file  mode  bits  other
62       than the file permission bits is unspecified.
63
64       In  the  octal  integer form of mode, the specified bits are set in the
65       file mode creation mask.
66
67       The file mode creation mask shall  be  set  to  the  resulting  numeric
68       value.
69
70       The  default  output  of a prior invocation of umask on the same system
71       with no operand also shall be recognized as a mask operand.
72
73

STDIN

75       Not used.
76

INPUT FILES

78       None.
79

ENVIRONMENT VARIABLES

81       The following environment  variables  shall  affect  the  execution  of
82       umask:
83
84       LANG   Provide  a  default value for the internationalization variables
85              that are unset or null. (See  the  Base  Definitions  volume  of
86              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
87              ables for the precedence of internationalization variables  used
88              to determine the values of locale categories.)
89
90       LC_ALL If  set  to a non-empty string value, override the values of all
91              the other internationalization variables.
92
93       LC_CTYPE
94              Determine the locale for  the  interpretation  of  sequences  of
95              bytes  of  text  data as characters (for example, single-byte as
96              opposed to multi-byte characters in arguments).
97
98       LC_MESSAGES
99              Determine the locale that should be used to  affect  the  format
100              and contents of diagnostic messages written to standard error.
101
102       NLSPATH
103              Determine the location of message catalogs for the processing of
104              LC_MESSAGES .
105
106

ASYNCHRONOUS EVENTS

108       Default.
109

STDOUT

111       When the mask operand is not specified, the umask utility shall write a
112       message to standard output that can later be used as a umask mask oper‐
113       and.
114
115       If -S is specified, the message shall be in the following format:
116
117
118              "u=%s,g=%s,o=%s\n", <owner permissions>, <group permissions>,
119                  <other permissions>
120
121       where the three values shall be combinations of letters from the set  {
122       r,  w, x}; the presence of a letter shall indicate that the correspond‐
123       ing bit is clear in the file mode creation mask.
124
125       If a mask operand is specified, there shall be  no  output  written  to
126       standard output.
127

STDERR

129       The standard error shall be used only for diagnostic messages.
130

OUTPUT FILES

132       None.
133

EXTENDED DESCRIPTION

135       None.
136

EXIT STATUS

138       The following exit values shall be returned:
139
140        0     The file mode creation mask was successfully changed, or no mask
141              operand was supplied.
142
143       >0     An error occurred.
144
145

CONSEQUENCES OF ERRORS

147       Default.
148
149       The following sections are informative.
150

APPLICATION USAGE

152       Since umask affects the current shell execution environment, it is gen‐
153       erally provided as a shell regular built-in.
154
155       In  contrast to the negative permission logic provided by the file mode
156       creation mask and the octal number form of the mask argument, the  sym‐
157       bolic  form  of  the mask argument specifies those permissions that are
158       left alone.
159

EXAMPLES

161       Either of the commands:
162
163
164              umask a=rx,ug+w
165
166
167              umask 002
168
169       sets the mode mask  so  that  subsequently  created  files  have  their
170       S_IWOTH bit cleared.
171
172       After  setting  the  mode  mask  with either of the above commands, the
173       umask command can be used to write out the current value  of  the  mode
174       mask:
175
176
177              $ umask
178              0002
179
180       (The  output  format is unspecified, but historical implementations use
181       the octal integer mode format.)
182
183
184              $ umask -S
185              u=rwx,g=rwx,o=rx
186
187       Either of these outputs can be used as the mask operand to a subsequent
188       invocation of the umask utility.
189
190       Assuming the mode mask is set as above, the command:
191
192
193              umask g-w
194
195       sets  the  mode  mask  so  that  subsequently  created files have their
196       S_IWGRP and S_IWOTH bits cleared.
197
198       The command:
199
200
201              umask -- -w
202
203       sets the mode mask so that subsequently created files  have  all  their
204       write  bits  cleared.  Note  that  mask operands -r, -w, -x or anything
205       beginning with a hyphen, must be preceded by "--" to keep it from being
206       interpreted as an option.
207

RATIONALE

209       Since umask affects the current shell execution environment, it is gen‐
210       erally provided as a shell regular built-in. If it is called in a  sub‐
211       shell  or  separate  utility  execution environment, such as one of the
212       following:
213
214
215              (umask 002)
216              nohup umask ...
217              find . -exec umask ... \;
218
219       it does not affect the file mode creation mask of  the  environment  of
220       the caller.
221
222       The  description  of the historical utility was modified to allow it to
223       use the symbolic modes of chmod. The -s option used in early  proposals
224       was  changed  to  -S  because -s could be confused with a symbolic_mode
225       form of mask referring to the S_ISUID and S_ISGID bits.
226
227       The default output style is implementation-defined to permit  implemen‐
228       tors  to  provide  migration to the new symbolic style at the time most
229       appropriate to their users. A -o flag to force octal  mode  output  was
230       omitted  because the octal mode may not be sufficient to specify all of
231       the information that may be present in the file mode creation mask when
232       more secure file access permission checks are implemented.
233
234       It  has been suggested that trusted systems developers might appreciate
235       ameliorating the requirement that the  mode  mask  "affects"  the  file
236       access  permissions,  since it seems access control lists might replace
237       the mode mask to some degree. The wording has been changed to say  that
238       it  affects  the file permission bits, and it leaves the details of the
239       behavior of how they affect the file access permissions to the descrip‐
240       tion in the System Interfaces volume of IEEE Std 1003.1-2001.
241

FUTURE DIRECTIONS

243       None.
244

SEE ALSO

246       Shell  Command  Language  ,  chmod  ,  the  System Interfaces volume of
247       IEEE Std 1003.1-2001, umask()
248
250       Portions of this text are reprinted and reproduced in  electronic  form
251       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
252       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
253       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
254       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
255       event of any discrepancy between this version and the original IEEE and
256       The Open Group Standard, the original IEEE and The Open Group  Standard
257       is  the  referee document. The original Standard can be obtained online
258       at http://www.opengroup.org/unix/online.html .
259
260
261
262IEEE/The Open Group                  2003                             UMASK(P)
Impressum