Umask Calculator

Enter a umask value to see the resulting default file and directory permissions.

Result

Files: 640 (rw-r-----) Dirs: 750 (rwxr-x---)
640 (rw-r-----)
750 (rwxr-x---)

How it is calculated

A umask is a mask of permission bits to remove. New files start from 666 and new directories from 777, so file mode = 666 & ~umask and directory mode = 777 & ~umask. Each octal digit covers one class, in order: owner, group, others, and within a digit read 4 = read, 2 = write, 1 = execute. A bit set in the umask is cleared in the result.

The input must be three or four octal digits (0 to 7 only). With four digits, only the last three are used, because the tool keeps just the permission bits. A value such as 089 or 22 is not accepted. Files start from 666, not 777, so a umask can never make a new regular file executable; that is why files and directories differ even under the same mask. The result is shown in octal and in the usual rwx text form.

Worked example

Enter the umask 027. Owner digit 0 removes nothing; group digit 2 removes write; others digit 7 removes everything. For files, 666 gives owner rw, group rw minus w = r, others none, which is 640 (rw-r-----). For directories, 777 gives owner rwx, group r-x, others none, which is 750 (rwxr-x---). So the owner keeps full access, the group can read and enter, and everyone else is shut out.

Try this example →

Common mistakes

  • Thinking the umask is the permission itself. It is the set of bits taken away, so 022 gives 644 for files, not 022.
  • Subtracting the digits as ordinary numbers. A umask is a bitwise operation: 666 minus 027 would be wrong, while 666 & ~027 gives 640.
  • Expecting new files to be executable. Files start from 666, so even umask 000 leaves 666 and the x bit has to be added with chmod.
  • Typing a digit 8 or 9, or only two digits such as 22. Only octal digits are accepted, in groups of three or four.
  • Assuming the umask changes existing files. It applies only to files and directories created afterwards by that process.

About this calculator

On Linux and Unix systems, new files and directories start from maximum default permissions — 666 (rw-rw-rw-) for files and 777 (rwxrwxrwx) for directories — and the umask value subtracts specific permission bits from that maximum using a bitwise AND with the complement of the mask. A umask of 022, for example, strips group and other write permission, leaving new files at 644 and new directories at 755.

System administrators and developers set the umask in shell profiles or service configs to control the default access level of everything a process creates, which matters for security on shared servers and multi-user systems.

Was this helpful?

You can pick up to 3 reactions.

Comments (1)

  • Editorial team

    A umask only takes permissions away, never adds them, and a program may still ask for stricter modes on its own, as SSH does for private keys. For a folder shared by a group, 002 gives files 664 and directories 775 so teammates can write, while 077 keeps everything private to the owner. Typing umask in your shell shows the current value. What setup are you trying to get right, a shared project or a web root?

Popular calculators

All Calculators