via Wikipedia infobox
umask
pubs.opengroup.org →The umask utility shall set the file mode creation mask of the current shell execution environment (see Shell Execution Environment ) to the value specified by the mask operand. This mask shall affect the initial value of the file permission bits of subsequently created files. If umask is called in a subshell or separate utility execution environment, such as one of the following: it shall not affect the file mode creation mask of the caller's environment. If the mask operand is not specified, the umask utility shall write to standard output the value of the file mode creation mask of the invoking process. A string specifying the new file mode creation mask. The string is treated in the same way as the mode operand described in the EXTENDED DESCRIPTION section for chmod . For a symbolic mode value, the new value of the file mode creation mask shall be the logical complement of the file permission bits portion of the file mode specified by the symbolic mode string. The interpretation of mode values that specify file mode bits other than the file permission bits is unspecified. In the octal integer form of mode , the specified bits are set in the file mode creation mask. The file mode creation mask shall be set to the resulting numeric value. Provide a default value for the internationalization variables that are unset or null. (See XBD Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.) If set to a non-empty string value, override the values of all the other internationalization variables. Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. [XSI) ] ![[Option Start]]( Determine the location of message catalogs for the processing of LC MESSAGES. ![[Option End]]( When the mask operand is not specified, the umask utility shall write a message to standard output that can later be used as a umask mask operand. The file mode creation mask was successfully changed, or no mask operand was supplied. Since umask affects the current shell execution environment, it is generally provided as a shell regular built-in. In contrast to the negative permission logic provided by the file mode creation mask and the octal number form of the mask argument, the symbolic form of the mask argument specifies those permissions that are left alone. sets the mode mask so that subsequently created files have their S IWOTH bit cleared. (The output format is unspecified, but historical implementations use the octal integer mode format.) sets the mode mask so that subsequently created files have their S IWGRP and S IWOTH bits cleared. it does not affect the file mode creation mask of the environment of the caller. The default output style is unspecified to permit implementors to provide migration to the new symbolic style at the time most appropriate to their users. A -o flag to force octal mode output was omitted because the octal mode may not be sufficient to specify all of the information that may be present in the file mode creation mask when more secure file access permission checks are implemented. It has been suggested that trusted systems developers might appreciate ameliorating the requirement that the mode mask "affects" the file access permissions, since it seems access control lists might replace the mode mask to some degree. The wording has been changed to say that it affects the file permission bits, and it leaves the details of the behavior of how they affect the file access permissions to the description in the System Interfaces volume of POSIX.1-2017.
~9 min read
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, , 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.
Excerpt from a page describing this subject · 10,826 chars · not written by Vinony
via Wikidata · CC0
Discovered by embedding cosine similarity (sentence-transformers MiniLM, 384-dim).