Skip to content

Umask calculator

Free, no sign-up Runs in your browser

Enter a umask such as 022 or 027 and see the permissions new files and directories get, in octal and in rwx form. Explains how the mask is applied.

As printed by the umask command: 022, 0027, 077.

Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.

How to use the umask calculator

  1. Enter the umask in octal, as the umask command prints it.
  2. Read the mode new files get and the mode new directories get.
  3. Compare 022, 027 and 077 with the example buttons.

About this tool

The umask decides which permissions a new file does not get. When a program creates a file it asks for a mode, normally 666 for a file and 777 for a directory, and the system clears every bit that is set in the umask. With the common umask 022, the write bits for group and others are removed: files come out 644 and directories 755.

It is a mask, not a subtraction, although the two often give the same answer. A umask of 033 does not turn 666 into 633. It clears write and execute for group and others, and since a new file had no execute bit to begin with, the result is 644. This calculator applies the mask bit by bit.

The umask is your default exposure. Under 022 every file you create is readable by all other accounts on the machine, which is how keys and configuration files leak on shared hosts. Service accounts and servers that hold secrets are better off with 027 or 077. A program may still ask for less than 666, as ssh-keygen does for private keys.

Sources

Questions

What does umask 022 mean?

New files are created 644 (rw-r--r--) and new directories 755 (rwxr-xr-x). The owner has full access, and everyone else can read but not write. It is the default on most Linux distributions.

What is the most secure umask?

077 gives new files 600 and new directories 700: only the owner has any access. 027 is a common middle ground for servers, letting the group read while giving others nothing.

Why are new files not executable even with umask 000?

Because programs ask for 666 when they create a regular file, so the execute bits are never requested. The umask can only remove permissions. Directories are requested with 777, which is why they do get execute.

How do I set the umask permanently?

For a user, put the umask command in the shell profile, such as ~/.profile. System-wide defaults are set in /etc/login.defs or through pam_umask on Linux. For a systemd service, use the UMask= setting in the unit file.

Related tools