UMASK(1) General Commands Manual UMASK(1)

umaskget or set the file mode creation mask

umask [-S] [mask]

The umask utility shall set the file mode creation mask of the current shell execution environment (see 3.12) 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 the mask operand is not specified, the umask utility shall write to standard output the value of the invoking process’s file mode creation mask.

The umask utility shall conform to the utility argument syntax guidelines described in 2.10.2. The following option shall be supported by the implementation:

Produce symbolic output. The default output style is unspecified, but shall be recognized on a subsequent invocation of umask on the same system as a mask operand to restore the previous file mode creation mask.

The following operand shall be supported by the implementation:

mask

A string specifying the new file mode creation mask. The string is treated in the same way as the mode operand described in chmod(1)
(chmod Extended Description). 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. In a symbolic_mode value, the permissions op characters + and - shall be interpreted relative to the current file mode creation mask; + shall cause the bits for the indicated permissions to be cleared in the mask; - shall cause the bits for the indicated permissions to be set in the mask.

The interpretation of mode values that specify file mode bits other than the file permission bits is unspecified. In the obsolescent octal integer form of mode, the specified bits shall be set in the file mode creation mask. The file mode creation mask shall be set to the resulting numeric value. As in chmod, application use of the octal number form for the mode values is obsolescent. The default output of a prior invocation of umask on the same system with no operand shall also be recognized as a mask operand. The use of an operand obtained in this way is not obsolescent, even if it is an octal number.

None.

None.

The following environment variables shall affect the execution of umask:

This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.

This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.

This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).

This variable shall determine the language in which messages should be written.

Default.

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. If −S is specified, the message shall be in the following format: "u=%s,g=%s,o=%s\n", <owner permissions>, <group permissions>, <other permissions> where the three values shall be combinations of letters from the set {r, w, x}; the presence of a letter shall indicate that the corresponding bit is clear in the file mode creation mask. If a mask operand is specified, there shall be no output written to standard output.

Used only for diagnostic messages.

None.

None.

The umask utility shall exit with one of the following values:

The file mode creation mask was successfully changed, or no mask operand was supplied.

An error occurred.

Default.

Since umask affects the current shell execution environment, it is generally provided as a shell regular built-in. If it is called in a subshell or separate utility execution environment, such as one of the following:

( umask 002) nohup umask ... find . -exec umask ... \;

it will not affect the file mode creation mask of the caller’s environment.

The table mapping octal mode values in chmod(1)
does not require that the symbolic constants have those particular values. 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. Either of the commands: umask a=rx,ug+w umask 002 sets the mode mask so that subsequently created files have their S_IWOTH bit cleared. After setting the mode mask with either of the above commands, the umask command can be used to write out the current value of the mode mask: $ umask 0002 (The output format is unspecified, but historical implementations use the obsolescent octal integer mode format.) $ umask -S u=rwx,g=rwx,o=rx Either of these outputs can be used as the mask operand to a subsequent invocation of the umask utility. Assuming the mode mask is set as above, the command: umask g-w sets the mode mask so that subsequently created files have their , and S_IWOTH bits cleared.

The command: umask -- -w sets the mode mask so that subsequently created files have all their write bits cleared. Note that mask operands −r, −w, −x, or anything beginning with a hyphen, must be preceded by -- to keep it from being interpreted as an option.

The description of the historical utility was modified to allow it to use the symbolic modes of chmod. The −s option used in earlier drafts was changed to −S because −s could be confused with a symbolic_mode form of mask referring to the and bits. The default output style is implementation defined to permit implementors to provide migration to the new symbolic style at the time most appropriate to their users. Earlier drafts of this standard specified an −o flag to force octal mode output. This was dropped 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 softening 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 leaves the details of the behavior of how they affect the file access permissions to the description in . 1 {8}.

September 1991 posix.fail