Create a file on most Linux systems and it arrives as rw-r--r--. Create a directory and it arrives as rwxr-xr-x. Nobody typed those permissions. They come from a single number every process carries, the umask, and from a rule that most tutorials describe slightly wrong. Every result below was produced on Ubuntu 24.04 by actually creating files under different masks, including a systemd service, a Python program and a directory with an access control list.
What the umask does
A mask, not a setting
The umask(2) manual describes the job precisely: when open(), mkdir() and similar calls create something, the permission bits set in the umask are turned off from the mode the program asked for. The umask never adds a permission. It only removes them.
The usual request is 0666 (rw-rw-rw-) for a file and 0777 (rwxrwxrwx) for a directory. The manual works the standard example: 0666 with a umask of 022 gives 0644, rw-r--r--. Programs ask for no execute bit on ordinary files, which is why a new file never comes out executable no matter how permissive the umask is.
The current value
$ umask
0022
$ umask -S
u=rwx,g=rx,o=rx
The -S form shows what the mask allows rather than what it blocks, which is often easier to read.
Checking a running process
The manual notes an awkward detail: the umask() system call cannot read the mask without also setting it. For any process already running, Linux shows the value in /proc. In a shell with a mask of 027, grep Umask /proc/self/status printed Umask: 0027. Replacing self with a process ID shows the mask of a running service or daemon, which is the quickest way to find out why a program keeps creating files with the wrong permissions, without restarting anything.

Common values, tested
One test per mask
Each mask was set in a subshell, then one file and one directory were created:
| umask | New file | New directory | Typical use |
|---|---|---|---|
| 022 | rw-r--r-- |
rwxr-xr-x |
System default: everyone may read |
| 002 | rw-rw-r-- |
rwxrwxr-x |
Shared group work |
| 027 | rw-r----- |
rwxr-x--- |
Group may read, others nothing |
| 077 | rw------- |
rwx------ |
Private: owner only |
| 777 | --------- |
--------- |
Owner can’t even read the new file |
Setting it symbolically
umask u=rwx,g=rx,o= sets what should be allowed instead of what should be blocked. In the test it produced 0027. Many people find this harder to get backwards.
Why it isn’t subtraction
The myth
Tutorials often say “subtract the umask from 666.” For 022 that gives 644, the right answer, which is why the shortcut survives. It breaks on odd digits.
The test
With a umask of 033, subtraction predicts 666 − 033 = 633, rw--wx-wx, a file that the group and everyone else could write and execute but not read. The real result:
$ (umask 033; touch s; stat -c "%a %A" s)
644 -rw-r--r--
The umask’s 3 means “block write and execute.” The file never asked for execute, so there was nothing to block there, and write was blocked as intended. The operation is a bitwise AND with the inverted mask, mode & ~umask, which never turns a bit on.
The directory catch
The same 033 produced directories of rwxr--r--. Group members and others could see the names inside but could not enter the directory or open anything in it, because entering a directory needs the execute bit. An odd-numbered umask almost always produces broken directories, which is why the common values are all even in the group and other positions.

What ignores the umask
Explicit modes and later changes
The umask only applies at creation time, and only to the mode a program asks for:
| Test, with umask 077 | Result |
|---|---|
mkdir -m 755 dm |
755 |
touch c; chmod 666 c |
666 |
cp of a 755 script |
700 |
cp -p of the same script |
755 |
mkdir -m sets the mode after creation, so the mask has no say. chmod changes existing files and never consults the umask at all. Plain cp starts from the source file’s mode and applies the umask, which is how a script copied under a strict mask lost its group and other permissions. cp -p preserves the original mode.
Programs
A Python program that created a file with os.open(..., 0o777) under a umask of 027 produced mode 750. The program asked for everything; the umask still took away group write and everything for others. That is the safety property: a program cannot accidentally create a world-writable file unless the process’s mask allows it.
Default ACLs
The umask(2) manual notes one exception: if the parent directory has a default ACL, the umask is ignored and the ACL is inherited instead. The test set a default ACL granting the group full access on a shared folder, then created a file and a directory inside it under a umask of 077:
-rw-rw-r-- shared/x
drwxrwxr-x shared/y
The strict umask had no effect. For a team folder where everyone must be able to edit everyone’s files, a default ACL is more reliable than asking every user to change their umask.
Where the value comes from
Inheritance
The manual says a child process inherits its parent’s umask through fork() and keeps it across execve(). That is why umask 077 typed into a shell affects every program launched from that shell, and nothing launched from anywhere else.
Login sessions
On Ubuntu, the value for logins starts in /etc/login.defs. The login.defs manual says UMASK there initializes the mask (022 if unset) and is the default for pam_umask. The test system had UMASK 022 and USERGROUPS_ENAB yes. The pam_umask manual explains the second setting: for a non-root user whose username matches their primary group name, the group bits of the mask are set to match the owner bits, so 022 becomes 002 and 077 becomes 007.
That is why many Ubuntu users find umask prints 0002 in their own sessions but 0022 as root. Every user gets a private group of their own, so letting that group write is harmless.
systemd services
Services do not log in, so none of that applies to them. The systemd.exec manual says UMask= defaults to 0022 for system units. Two oneshot test units in an isolated systemd 255 container confirmed it: one without a setting printed 0022 and created a rw-r--r-- file; one with UMask=0077 printed 0077 and created rw-------. A service that writes private data, such as a backup job storing database dumps, should set UMask=0077 in its unit rather than relying on a shell setting it will never see.

Git clones and tar archives
Git stores almost no permissions
Git records only whether a file is executable. In the test repository, a file set to 666 and a script set to 755 were stored as 100644 and 100755, nothing more. Cloning that repository under a umask of 077 produced:
600 gclone/a.txt
700 gclone/run.sh
The clone applied the cloning user’s mask to Git’s two modes. The 666 on the original file was never recorded, so it could not be restored. A deployment that clones code under a strict mask and then serves it with a web server running as a different user will find the files unreadable, and the fix belongs in the deploy step, not in the repository.
tar behaves differently for root
The tar manual for Ubuntu 24.04 lists permission preservation, -p or --same-permissions, as the default for the superuser, and applying the umask, --no-same-permissions, as the default for ordinary users. An archive holding a single 666 file was extracted three ways under a umask of 077:
| Who extracted it | Resulting mode |
|---|---|
| root, defaults | 666 |
root, --no-same-permissions |
600 |
| an ordinary user, defaults | 600 |
The same archive gave different permissions depending on who extracted it. Restoring a backup as root reproduces the archive’s permissions exactly, including any mistakes stored in it. Extracting a downloaded archive as root can quietly install world-writable files that an ordinary user would never have received.
One confirmation of the Ubuntu default
A fresh test user created with useradd -m got a private group of the same name. Logging in as that user with su - and running umask printed 0002, the user-private-group adjustment pam_umask describes, while root’s sessions on the same machine showed 0022.
Choosing a value
Short rules from the tests
- Personal machine: the default (022, or 002 with user private groups) is fine.
- Server with sensitive files or multiple users: 027 or 077 in the shell profile, and
UMask=0077on services that write secrets. - Shared project folder: a default ACL on the folder instead of changing everyone’s umask.
- Never an odd digit in the group or other positions, unless directories nobody can enter are the goal.
The number is small, invisible, and set long before anyone types a command. It still decides who can read every file a session ever creates.
Sources
- umask(2), Linux manual page: https://man7.org/linux/man-pages/man2/umask.2.html
- login.defs(5), Ubuntu 24.04 manual page: https://manpages.ubuntu.com/manpages/noble/man5/login.defs.5.html
- pam_umask(8), Ubuntu 24.04 manual page: https://manpages.ubuntu.com/manpages/noble/man8/pam_umask.8.html
- systemd.exec(5), Ubuntu 24.04 manual page: https://manpages.ubuntu.com/manpages/noble/man5/systemd.exec.5.html
- tar(1), Ubuntu 24.04 manual page: https://manpages.ubuntu.com/manpages/noble/man1/tar.1.html
