User Commands umask(1)
NAME
umask - get or set the file mode creation mask
SYNOPSIS
/usr/bin/umask [-S] [mask]
shumask [ooo]
cshumask [ooo]
kshumask [-S] [mask]
ksh93umask [-S] [mask]
DESCRIPTION
The umask utility sets the file mode creation mask of the
current shell execution environment to the value specified by the mask operand. This mask affects the initial value of the file permission bits of subsequently created files. Ifumask is called in a subshell or separate utility execution
environment, such as one of the following:(umask 002)
nohup umask ...
find . -exec umask ...
it does not affect the file mode creation mask of thecaller's environment. For this reason, the /usr/bin/umask
utility cannot be used to change the umask in an ongoing
session. Its usefulness is limited to checking the caller'sumask. To change the umask of an ongoing session you must
use one of the shell builtins.If the mask operand is not specified, the umask utility
writes the value of the invoking process's file mode crea-
tion mask to standard output. shSunOS 5.11 Last change: 17 Sep 2007 1
User Commands umask(1)
The user file-creation mode mask is set to ooo. The three
octal digits refer to read/write/execute permissions for owner, group, and other, respectively (see chmod(1),chmod(2), and umask(2)). The value of each specified digit
is subtracted from the corresponding ``digit'' specified by the system for the creation of a file (see creat(2)). Forexample, umask 022 removes write permission for group and
other. Files (and directories) normally created with mode 777 become mode 755. Files (and directories) created with mode 666 become mode 644). o If ooo is omitted, the current value of the mask is printed.o umask is recognized and executed by the shell.
o umask can be included in the user's .profile (see
profile(4)) and invoked at login to automatically set the user's permissions on files or directories created. cshSee the description above for the Bourne shell (sh)umask
built-in.
kshThe user file-creation mask is set to mask. mask can either
be an octal number or a symbolic value as described inchmod(1). If a symbolic value is given, the new umask value
is the complement of the result of applying mask to the com-
plement of the previous umask value. If mask is omitted, the
current value of the mask is printed. ksh93umask sets the file creation mask of the current shell exe-
cution environment to the value specified by the maskoperand. This mask affects the file permission bits of sub-
sequently created files. mask can either be an octal number or a symbolic value as described in chmod(1). If a symbolicvalue is specified, the new file creation mask is the com-
plement of the result of applying mask to the complement of the current file creation mask. If mask is not specified,umask writes the value of the file creation mask for the
current process to standard output. OPTIONS kshThe following option is supported for /usr/bin/umask and
umask in ksh:
-S Produces symbolic output.
SunOS 5.11 Last change: 17 Sep 2007 2
User Commands umask(1)
The default output style is unspecified, but will be recog-
nized on a subsequent invocation of umask on the same system
as a mask operand to restore the previous file mode creation mask. ksh93 The following option is supported in ksh93:-S Causes the file creation mask to be written or treated
as a symbolic value rather than an octal number. OPERANDS The following operand is supported: mask A string specifying the new file mode creation mask. The string is treated in the same way as the mode operand described in the chmod(1) manual page.For a symbolic_mode value, the new value of the file
mode creation mask is the logical complement of thefile permission bits portion of the file mode speci-
fied by the symbolic_mode string.
In a symbolic_mode value, the permissions op charac-
ters + and - are interpreted relative to the current
file mode creation mask. + causes the bits for theindicated permissions to be cleared in the mask. -
causes the bits of the indicated permissions to be set in the mask. The interpretation of mode values that specify file mode bits other than the file permission bits is unspecified. The file mode creation mask is set to the resulting numeric value.The default output of a prior invocation of umask on
the same system with no operand will also be recog-
nized as a mask operand. The use of an operand obtained in this way is not obsolescent, even if it is an octal number.OUTPUT
When the mask operand is not specified, the umask utility
will write a message to standard output that can later beused as a umask mask operand.
SunOS 5.11 Last change: 17 Sep 2007 3
User Commands umask(1)
If -S is specified, the message will be in the following
format:"u=%s,g=%s,o=%s\n", owner permissions, group permissions, \
other permissions where the three values will be combinations of letters from the set {r, w, x}. The presence of a letter will indicatethat the corresponding bit is clear in the file mode crea-
tion mask. If a mask operand is specified, there will be no output written to standard output.EXAMPLES
Example 1 Using the umask Command
The examples in this section refer to the /usr/bin/umask
utility and the ksh umask builtin.
Either of the commands:umask a=rx,ug+w
umask 002
sets the mode mask so that subsequently created files havetheir S_IWOTH bit cleared.
After setting the mode mask with either of the above com-
mands, the umask command can be used to write the current
value of the mode mask:example$ umask
0002SunOS 5.11 Last change: 17 Sep 2007 4
User Commands umask(1)
The output format is unspecified, but historical implementa-
tions use the obsolescent octal integer mode format.example$ umask -S
u=rwx,g=rwx,o=rx Either of these outputs can be used as the mask operand to asubsequent invocation of the umask utility.
Assuming the mode mask is set as above, the command:umask g-w
sets the mode mask so that subsequently created files havetheir S_IWGRP and S_IWOTH bits cleared.
The command:umask --w
sets the mode mask so that subsequently created files have all their write bits cleared. Notice that mask operands r,w, x, or anything beginning with a hyphen (-), must be pre-
ceded by - to keep it from being interpreted as an option.
ENVIRONMENT VARIABLES See environ(5) for descriptions of the following environmentvariables that affect the execution of umask: LANG, LC_ALL,
LC_COLLATELC_CTYPE, LC_MESSAGES, and NLSPATH.
EXIT STATUS The following exit values are returned: 0 The file mode creation mask was successfully changed, or no mask operand was supplied.SunOS 5.11 Last change: 17 Sep 2007 5
User Commands umask(1)
>0 An error occurred.ATTRIBUTES
See attributes(5) for descriptions of the following attri-
butes:/usr/bin/umask, csh, ksh, sh
____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | SUNWcs ||_____________________________|_____________________________|
| Interface Stability | Committed ||_____________________________|_____________________________|
| Standard | See standards(5). ||_____________________________|_____________________________|
ksh93____________________________________________________________
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
|_____________________________|_____________________________|
| Availability | SUNWcsu ||_____________________________|_____________________________|
| Interface Stability | Volatile ||_____________________________|_____________________________|
SEE ALSO
chmod(1), csh(1), ksh(1), ksh93(1), sh(1), chmod(2),creat(2), umask(2), profile(4), attributes(5), environ(5),
standards(5)SunOS 5.11 Last change: 17 Sep 2007 6