How to use the umask calculator
- Choose to start from a umask or from a wanted directory mode.
- Enter the value: an octal umask such as 022, a symbolic one such as u=rwx,g=rx,o=rx, or directory permissions such as 755.
- Read the permissions that new files and new directories get, and the umask command to use.
- Compare the octal and the symbolic forms to see how they relate.
Formula
file permissions = 666 AND NOT umask
directory permissions = 777 AND NOT umask
umask for a wanted directory mode = 777 AND NOT mode
symbolic umask (umask -S) lists the permissions that stay allowed
Programs usually ask for 666 when they create a file and 777 when they create a directory. The umask removes bits from that request. Only the last three octal digits are used.
The common values 022, 077 and 002
With umask 022, new files get 644 (rw-r--r--) and new directories get 755 (rwxr-xr-x). The symbolic form is u=rwx,g=rx,o=rx. The bits removed are the write bits for group and others.
With umask 077, files get 600 and directories get 700, so only the owner has access. With umask 002, files get 664 and directories get 775, which suits a group that shares files. If you want new directories to be 775, the page gives umask 002, and new files then get 664.
Why files never get the execute bit
A file creation call usually asks for mode 666, which has no execute bits. The umask can only remove bits, never add them, so a new file does not become executable by default. You make a script executable on purpose with chmod. Directories need the execute bit to be entered, so programs ask for 777, and the umask trims that.
The umask belongs to a process and is inherited by the programs it starts. A value set in a shell profile applies to files made from that shell. Services and cron jobs may have their own umask.
Related tools
To set the mode of a file that already exists, use the Chmod Calculator. To work with masks of your own, try the Bit Field Mask Generator and the Bitwise Calculator.
Assumptions and limits
- Files are requested with mode 666 and directories with mode 777.
- Only the last three octal digits of the umask are used.
- Access control lists and special filesystems can change the result.
- Special bits such as setuid, setgid and sticky are not covered.
- The umask shown when the page opens is an example.
Frequently asked questions
What does umask 022 do?
It removes write permission for the group and for others. New files become 644 and new directories become 755, so only the owner can change them.
Is the umask the same as the permissions?
No, it is the opposite. The permissions are what remains after the umask removes bits, so a larger umask gives stricter permissions.
What do the four digits in 0022 mean?
On Linux only the last three digits change permissions. The first digit has no effect on new files, so 0022 and 022 are the same.
Can I get a new file with the execute bit?
Not from the umask alone. A program must ask for it. Most create files with mode 666, which leaves execute off until you use chmod.