umask(1)umask(1)NAMEumask - set or display the file mode creation mask
The command sets the value of the file mode creation mask or displays
the current one. The mask affects the initial value of the file mode
(permission) bits for subsequently created files.
Setting the File Mode Creation Mask
The command sets a new file mode creation mask for the current shell
execution environment. mask can be a symbolic or numeric (obsolescent)
A symbolic mask provides a flexible way of modifying the mask permis‐
sion bits individually or as a group. A numeric mask specifies all the
permission bits at one time.
When a mask is specified, no output is written to standard output. A
symbolic mask replaces or modifies the current file mode creation mask.
It is specified as a comma-separated list of operations in the follow‐
ing format. Whitespace is not permitted.
The fields can have the following values:
who One or more of the following letters:
Modify permissions for user (owner).
Modify permissions for group.
Modify permissions for others.
Modify permissions for all
operator One of the following symbols:
Add permissions to the existing mask for
Delete permissions from the existing mask
Replace the existing mask for
who with permissions.
permissions One or more of the following letters:
The read permission.
The write permission.
The execute/search permission.
If one or two of the fields are omitted, the following table applies:
Format Entered Effect │ Input Equals
who Delete current permissions for who │
operator No action │ (none)
permissions Equal to: │
Delete current permissions for who │
No action │ (none)
No action │ (none)
whopermissions Equal to: │
operatorpermissions Equal to: │
A numeric mask replaces the current file mode creation mask. It is
specified as an unsigned octal integer, constructed from the logical OR
(sum) of the following mode bits (leading zeros can be omitted):
Displaying the Current Mask Value
To display the current file mode creation mask value, use one of the
Print the current file mode creation mask in a symbolic format:
The characters (read), (write), and (exe‐
cute/search) represent the bits that are clear in
the mask for (user/owner), (group), and (other).
All other bits are set.
Print the current file mode creation mask as an octal value.
The zero bits in the numeric value correspond to
the displayed and permission characters in the
symbolic value. The one bits in the numeric
value correspond to the missing permission char‐
acters in the symbolic value.
Depending on implementation, the display consists
of one to four octal digits; the first digit is
always zero (see DEPENDENCIES). The rightmost
three digits (leading zeros implied as needed)
represent the bits that are set or clear in the
Both forms produce output that can be used as the mask argument to set
the mask in a subsequent command.
When a new file is created (see creat(2)), each bit that is set in the
file mode creation mask causes the corresponding permission bit in the
the file mode to be cleared (disabled). Conversely, bits that are
clear in the mask allow the corresponding file mode bits to be enabled
in newly created files.
For example, the mask (octal disables group and other write permis‐
sions. As a result, files normally created with a file mode shown by
the command as (octal become mode (octal while files created with file
mode (octal become mode (octal
Note that the file creation mode mask does not affect the set-user-id,
set-group-id, or "sticky" bits.
The file creation mode mask is also used by the command (see chmod(1)).
Since affects the current shell execution environment, it is generally
provided as a shell regular built-in (see DEPENDENCIES).
If is called in a subshell or separate utility execution environment,
such as one of the following:
it does not affect the file mode creation mask of the calling environ‐
The default mask is (octal
exits with one of the following values:
The file mode creation mask was successfully changed
or no mask operand was supplied.
An error occurred.
In these examples, each line show an alternate way of accomplishing the
Set the value to produce read and write permissions for the file's
owner and read permissions for all others displays on newly created
Set the value to produce read, and write permissions for the file's
owner, read-only for others users in the same group, and no access to
Set the value to deny read, write, and execute permissions to everyone
Add the write permission to the current mask for everyone (there is no
equivalent numeric mode):
If you set a mask that prevents read or write access for the user
(owner), many programs, such as editors, that create temporary files
will fail because they cannot access the file data.
The command is implemented both as a separate executable file and as
built-in shell commands.
POSIX Shell and Separate File
All features are supported (see sh-posix(1)). The numeric mask display
uses a minimum of two digits.
The option is not supported in the Korn shell built-in command (see
ksh(1)). The numeric mask display uses a minimum of two digits.
The option and symbolic mask values are not supported in the C shell
built-in command (see csh(1)). The numeric mask display uses a minimum
of one digit.
SEE ALSOchmod(1), csh(1), ksh(1), sh-posix(1), sh(1), chmod(2), creat(2),