2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46 .\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
48 .TH UMASK 1 "Sep 17, 2007"
50 umask \- get or set the file mode creation mask
54 \fB/usr/bin/umask\fR [\fB-S\fR] [\fImask\fR]
60 \fBumask\fR [\fIooo\fR]
66 \fBumask\fR [\fIooo\fR]
72 \fBumask\fR [\fB-S\fR] [\fImask\fR]
78 \fBumask\fR [\fB-S\fR] [\fImask\fR]
84 The \fBumask\fR utility sets the file mode creation mask of the current shell
85 execution environment to the value specified by the \fImask\fR operand. This
86 mask affects the initial value of the file permission bits of subsequently
87 created files. If \fBumask\fR is called in a subshell or separate utility
88 execution environment, such as one of the following:
94 find . -exec umask ...
101 it does not affect the file mode creation mask of the caller's environment. For
102 this reason, the \fB/usr/bin/umask\fR utility cannot be used to change the
103 umask in an ongoing session. Its usefulness is limited to checking the caller's
104 umask. To change the umask of an ongoing session you must use one of the shell
108 If the \fImask\fR operand is not specified, the \fBumask\fR utility writes the
109 value of the invoking process's file mode creation mask to standard output.
113 The user file-creation mode mask is set to \fIooo\fR. The three octal digits
114 refer to read/write/execute permissions for owner, group, and other,
115 respectively (see \fBchmod\fR(1), \fBchmod\fR(2), and \fBumask\fR(2)). The
116 value of each specified digit is subtracted from the corresponding ``digit''
117 specified by the system for the creation of a file (see \fBcreat\fR(2)). For
118 example, \fBumask\fR \fB022\fR removes write permission for group and other.
119 Files (and directories) normally created with mode \fB777\fR become mode
120 \fB755\fR. Files (and directories) created with mode \fB666\fR become mode
126 If \fIooo\fR is omitted, the current value of the mask is printed.
132 \fBumask\fR is recognized and executed by the shell.
138 \fBumask\fR can be included in the user's \fB\&.profile\fR (see
139 \fBprofile\fR(4)) and invoked at login to automatically set the user's
140 permissions on files or directories created.
145 See the description above for the Bourne shell (\fBsh\fR)\fBumask\fR built-in.
149 The user file-creation mask is set to \fImask\fR. \fImask\fR can either be an
150 octal number or a symbolic value as described in \fBchmod\fR(1). If a symbolic
151 value is given, the new \fBumask\fR value is the complement of the result of
152 applying \fImask\fR to the complement of the previous umask value. If
153 \fImask\fR is omitted, the current value of the mask is printed.
157 \fBumask\fR sets the file creation mask of the current shell execution
158 environment to the value specified by the \fBmask\fI\fR\fR operand. This mask
159 affects the file permission bits of subsequently created files. \fImask\fR can
160 either be an octal number or a symbolic value as described in chmod(1). If a
161 symbolic value is specified, the new file creation mask is the complement of
162 the result of applying \fImask\fR to the complement of the current file
163 creation mask. If \fImask\fR is not specified, \fBumask\fR writes the value of
164 the file creation mask for the current process to standard output.
169 The following option is supported for \fB/usr/bin/umask\fR and \fBumask\fR in
177 Produces symbolic output.
182 The default output style is unspecified, but will be recognized on a subsequent
183 invocation of \fBumask\fR on the same system as a \fImask\fR operand to restore
184 the previous file mode creation mask.
188 The following option is supported in \fBksh93\fR:
195 Causes the file creation mask to be written or treated as a symbolic value
196 rather than an octal number.
202 The following operand is supported:
209 A string specifying the new file mode creation mask. The string is treated in
210 the same way as the \fImode\fR operand described in the \fBchmod\fR(1) manual
213 For a \fIsymbolic_mode\fR value, the new value of the file mode creation mask
214 is the logical complement of the file permission bits portion of the file mode
215 specified by the \fIsymbolic_mode\fR string.
217 In a \fIsymbolic_mode\fR value, the permissions \fIop\fR characters \fB+\fR and
218 \fB\(mi\fR are interpreted relative to the current file mode creation mask.
219 \fB+\fR causes the bits for the indicated permissions to be cleared in the
220 mask. \fB\(mi\fR causes the bits of the indicated permissions to be set in the
223 The interpretation of \fImode\fR values that specify file mode bits other than
224 the file permission bits is unspecified.
226 The file mode creation mask is set to the resulting numeric value.
228 The default output of a prior invocation of \fBumask\fR on the same system with
229 no operand will also be recognized as a \fImask\fR operand. The use of an
230 operand obtained in this way is not obsolescent, even if it is an octal number.
236 When the \fImask\fR operand is not specified, the \fBumask\fR utility will
237 write a message to standard output that can later be used as a \fBumask\fR
241 If \fB-S\fR is specified, the message will be in the following format:
245 "u=%s,g=%s,o=%s\en", \fIowner permissions\fR, \fIgroup permissions\fR, \e
246 \fIother permissions\fR
253 where the three values will be combinations of letters from the set
254 \fB{\fRr\fB,\fR \fBw\fR, \fBx\fR}. The presence of a letter will indicate that
255 the corresponding bit is clear in the file mode creation mask.
258 If a \fImask\fR operand is specified, there will be no output written to
262 \fBExample 1 \fRUsing the \fBumask\fR Command
265 The examples in this section refer to the \fB/usr/bin/umask\fR utility and the
266 \fBksh umask\fR builtin.
270 Either of the commands:
283 sets the mode mask so that subsequently created files have their \fBS_IWOTH\fR
288 After setting the mode mask with either of the above commands, the \fBumask\fR
289 command can be used to write the current value of the mode mask:
302 The output format is unspecified, but historical implementations use the
303 obsolescent octal integer mode format.
308 example$ \fBumask -S\fR
316 Either of these outputs can be used as the mask operand to a subsequent
317 invocation of the \fBumask\fR utility.
321 Assuming the mode mask is set as above, the command:
333 sets the mode mask so that subsequently created files have their \fBS_IWGRP\fR
334 and \fBS_IWOTH\fR bits cleared.
350 sets the mode mask so that subsequently created files have all their write bits
351 cleared. Notice that \fImask\fR operands \fBr\fR, \fBw\fR, \fBx\fR, or anything
352 beginning with a hyphen (\fB\(mi\fR), must be preceded by \fB-\fR to keep it
353 from being interpreted as an option.
355 .SH ENVIRONMENT VARIABLES
358 See \fBenviron\fR(5) for descriptions of the following environment variables
359 that affect the execution of \fBumask\fR: \fBLANG\fR, \fBLC_ALL\fR,
360 \fBLC_COLLATE\fR\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
364 The following exit values are returned:
371 The file mode creation mask was successfully changed, or no \fImask\fR operand
387 See \fBattributes\fR(5) for descriptions of the following attributes:
388 .SS "/usr/bin/umask, csh, ksh, sh"
396 ATTRIBUTE TYPE ATTRIBUTE VALUE
398 Interface Stability Standard
409 ATTRIBUTE TYPE ATTRIBUTE VALUE
411 Interface Stability External
417 \fBchmod\fR(1), \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1),
418 \fBchmod\fR(2), \fBcreat\fR(2), \fBumask\fR(2), \fBprofile\fR(4),
419 \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)