Umask

umask
Original author(s)AT&T Bell Laboratories
Developer(s)Various open-source and commercial developers
Initial release1978 (1978)
Operating systemUnix and Unix-like
PlatformCross-platform
TypeCommand

umask is a shell command that reports or sets the mask value that limits the file permissions for newly created files in many Unix and Unix-like file systems. A system call with the same name, umask(), provides access to the mask value stored in the operating system (OS), and the command provides shell user access to the system call. Additionally, the mask value, formally file mode creation mask, is often referred to as the umask.

When a new file is created, its access permissions are restricted by the stored umask mask value. The file's permission bits that each grant access are cleared by corresponding bits of the mask that are set. Set bits of the mask disallow the permission and clear bits of the mask allow the permission. The otherwise default value of a file's permissions is defined elsewhere. The mask just prevents corresponding bits of the default. The mask acts as a last-stage filter that strips away permissions as a file is created; each bit that is set strips away its corresponding permission. Permissions may be changed later including via the chmod command.

The operating system maintains a umask mask value for each process that is accessible via the umask command and umask() system call. When a process spawns a new process, the child inherits the mask from its parent.

Generally, the mask only affects file permissions during the creation of new files; however, the chmod command checks the mask when the mode options are specified using symbolic mode and a reference to a class of users is not specified.

The umask command is used with Unix-like operating systems, and the umask() system call is defined in the POSIX.1 specification.