# Umask

**Umask** (short for user file-creation mode mask) is a per-process setting in Unix and [Unix-like](https://www.edgepedia.org/unix-like) operating systems that determines which permission bits are turned off from the mode argument when a process creates a new file or directory. The kernel-level interface is the `umask()` system call, and most shells expose a `umask` builtin command for viewing and changing it.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup><sup> • </sup><sup>[2](https://www.oreilly.com/library/view/practical-unix-and/0596003234/ch06s04.html)</sup>

| Key fact | Detail |
|---|---|
| What it does | Permissions set in the mask are cleared from the mode argument of file-creating calls such as `open(2)` and `mkdir(2)`; the effective mode is `mode & ~umask`.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> |
| Typical default | Octal 022 (`S_IWGRP \| S_IWOTH`), so a file created with mode 0666 ends up 0644 (`rw-r--r--`).<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> |
| System call | `mode_t umask(mode_t mask)` in `<sys/stat.h>`; only the file permission bits (`mask & 0777`) are used, and the previous mask is returned.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> |
| Inheritance | A child created by `fork(2)` inherits the parent's umask; `execve(2)` leaves it unchanged.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> |
| ACL exception | If the parent directory has a default ACL, the umask is ignored and the default ACL is inherited instead.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> |
| Standardization | POSIX.1-2008; earlier conformance to POSIX.1-2001, SVr4, and 4.3BSD.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> |

## How the mask works

The umask is a set of permission bits that the system clears when a file is created. The POSIX `umask()` function sets the process's file mode creation mask and returns the previous value; bit positions set in the mask are cleared in the mode of the created file, and the mask is applied by `open()`, `creat()`, `mkdir()`, and `mkfifo()`.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup><sup> • </sup><sup>[3](https://linux.die.net/man/3/umask)</sup> In the absence of a default ACL, the mode of a created file is `mode & ~umask`.<sup>[4](https://www.kernel.org/pub/linux/docs/man-pages/book/man-pages-6.06.pdf)</sup>

The usual arithmetic is easiest to see in octal. With the typical default mask of 022 and a mode argument of 0666 (`rw-rw-rw-`), the created file receives 0644 (`rw-r--r--`), because `0666 & ~022 = 0644`.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> The mask therefore specifies permissions the user does *not* want granted by default to newly created files and directories.<sup>[2](https://www.oreilly.com/library/view/practical-unix-and/0596003234/ch06s04.html)</sup>

The system call always succeeds and returns the previous mask value.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> This design has one consequence worth knowing: it is impossible to read a process's umask without simultaneously changing it, and a second call is needed to restore the original value. Because those two steps are not atomic, multithreaded programs can encounter races around them.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup>

## Default values and scope

The typical default value for the process umask is octal 022, which removes write permission for group and other from whatever mode the program requests.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> FreeBSD documents the same default, `S_IWGRP|S_IWOTH` (022).<sup>[5](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+12.4-RELEASE&query=umask&sektion=2)</sup>

The mask reaches beyond ordinary files. It also affects the permissions assigned to POSIX IPC objects created with `mq_open(3)`, `sem_open(3)`, and `shm_open(3)`, to FIFOs created with `mkfifo(3)`, and to UNIX domain sockets. System V IPC objects created with `msgget(2)`, `semget(2)`, and `shmget(2)` are not affected.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup>

## Inheritance and inspection

A child process created via `fork(2)` inherits its parent's umask, and the mask survives `execve(2)` unchanged, so a mask set at login or in a shell profile propagates to everything the user runs.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> The Bash reference manual lists the file creation mode mask, as set by `umask` or inherited from the shell's parent, as part of the shell's execution environment, and commands run in a separate execution environment inherit it.<sup>[6](https://www.gnu.org/software/bash/manual/html_node/Command-Execution-Environment.html)</sup>

Since Linux 4.7, the umask of any process can be read from the `Umask` field of `/proc/pid/status`. A process can inspect this field in `/proc/self/status` to retrieve its own umask without changing it, avoiding the read-modify-restore race described above.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup>

## The shell command

POSIX defines a `umask` utility that sets the file mode creation mask of the current shell execution environment to the value of its mask operand, affecting the initial permission bits of subsequently created files.<sup>[7](https://www.man7.org/linux/man-pages/man1/umask.1p.html)</sup> In Bash, `umask [-p] [-S] [mode]` sets the shell process's file creation mask: a mode beginning with a digit is interpreted as an octal number, and any other mode is interpreted as a symbolic mask similar to one accepted by `chmod`. With no mode argument, `umask` prints the current value; with `-S` it prints the mask in symbolic format, and with `-p` the output is in a form that can be reused as input.<sup>[8](https://www.gnu.org/s/bash/manual/bash.html)</sup>

## Interaction with ACLs

[Access control](https://www.edgepedia.org/access-control) lists (ACLs) provide a finer-grained permission mechanism than the nine permission bits, and when a default ACL is present the umask steps aside. When a default ACL exists on the parent directory, the umask plays no role: the default ACL is what gets inherited, permission bits are determined from that inherited ACL, and the only bits cleared are those missing from the mode argument.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup> A default ACL of `u::rwx,g::r-x,o::r-x` is equivalent in effect to a umask of 022: combined with a mode argument of 0666, it yields file permissions of 0644.<sup>[1](https://www.man7.org/linux/man-pages/man2/umask.2.html)</sup>

## Practical notes

The mask only removes bits; it cannot add permissions the creating program did not request. Programs that need specific permissions on a file they create must call `chmod` afterward, since the umask may have stripped bits from the requested mode.

The mkdir utility illustrates how the mask enters even standard tooling: POSIX specifies that it calls `mkdir()` with the mode `(S_IWUSR|S_IXUSR|~filemask)&0777`, where `filemask` is the process's file mode creation mask, and that intermediate directories are created with the default modified by `u+wx` so their creation cannot be blocked by the mask.<sup>[9](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/mkdir.html)</sup>

## References

1. [umask(2) - Linux manual page, man-pages project](https://www.man7.org/linux/man-pages/man2/umask.2.html)
2. [The umask, Practical UNIX and Internet Security, 3rd Edition, O'Reilly](https://www.oreilly.com/library/view/practical-unix-and/0596003234/ch06s04.html)
3. [umask(3) - POSIX Programmer's Manual via Linux man page](https://linux.die.net/man/3/umask)
4. [The Linux man-pages Book, man-pages 6.06](https://www.kernel.org/pub/linux/docs/man-pages/book/man-pages-6.06.pdf)
5. [UMASK(2), FreeBSD 12.4-RELEASE Manual Pages](https://man.freebsd.org/cgi/man.cgi?manpath=FreeBSD+12.4-RELEASE&query=umask&sektion=2)
6. [Command Execution Environment, Bash Reference Manual, GNU](https://www.gnu.org/software/bash/manual/html_node/Command-Execution-Environment.html)
7. [umask(1p) - Linux manual page (POSIX Programmer's Manual)](https://www.man7.org/linux/man-pages/man1/umask.1p.html)
8. [Bash Reference Manual, GNU](https://www.gnu.org/s/bash/manual/bash.html)
9. [mkdir, POSIX.1-2024 Shell and Utilities](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/mkdir.html)

---
*Topic: Encyclopedia › Technology and the built world › Computing and digital systems › Software and programming › Operating systems › Unix-like and Linux › Unix, BSD, and kernel internals*

*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

*Copyright 2026 EdgeChat AI, a subsidiary of Biostate AI.*

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license
