Back to tools

Umask Calculator

What is umask?

umask (user file-creation mode mask) is a shell command and system call in Linux and Unix that determines the default permissions assigned to newly created files and directories. It acts as a permission mask: the system uses a base value of 666 (rw-rw-rw-) for files and 777 (rwxrwxrwx) for directories, and the umask subtracts permissions from that base. The formula is: final permissions = base value - umask. Internally, the kernel applies the binary operation base & ~umask. For instance, with umask 022, a new file gets 644 (rw-r--r--) and a new directory gets 755 (rwxr-xr-x).

Umask vs chmod

The key difference lies in when each operates. umask sets the default permissions for brand new files and directories before they are created. It acts as a preventative filter that strips away permissions at creation time through open() or mkdir() system calls. chmod, on the other hand, changes the permissions of files and directories that already exist on the system. While umask defines an upper boundary that new files cannot exceed, chmod can add or remove any permission on existing files regardless of the umask value.

Common umask values

  • 000 — No restrictions. Files: 666, directories: 777. Only recommended in controlled temporary environments.
  • 002 — Group writable. Files: 664, directories: 775. Useful in collaborative projects.
  • 022 — Default on most Linux distributions. Files: 644, directories: 755.
  • 027 — Group restrictive. Files: 640, directories: 750. Group read-only, others no access.
  • 077 — Fully private. Files: 600, directories: 700. Only owner has access.
  • 007 — Group full control. Files: 660, directories: 770. Group can read and write.