PROLOGThis manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
NAMEumask --- get or set the file mode creation mask
umask [-S] [mask]
DESCRIPTIONThe umask utility shall set the file mode creation mask of the current shell execution environment (see Section 2.12, 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:
(umask 002) nohup umask ... find . -exec umask ... \;
OPTIONSThe umask utility shall conform to the Base Definitions volume of POSIX.1-2008, Section 12.2, Utility Syntax Guidelines. The following option shall be supported:
- 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.
OPERANDSThe following operand shall be supported:
A string specifying the new file mode creation mask. The string is
treated in the same way as the
operand described in the EXTENDED DESCRIPTION section for
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 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. The default output of a prior invocation of umask on the same system with no operand also shall be recognized as a mask operand.
ENVIRONMENT VARIABLESThe following environment variables shall affect the execution of umask:
- Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1-2008, Section 8.2, 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 for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments).
Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogs for the processing of LC_MESSAGES.
STDOUTWhen 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>
STDERRThe standard error shall be used only for diagnostic messages.
EXIT STATUSThe following exit values shall be returned:
- The file mode creation mask was successfully changed, or no mask operand was supplied.
- An error occurred.
CONSEQUENCES OF ERRORSDefault.
The following sections are informative.
APPLICATION USAGESince 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.
EXAMPLESEither of the commands:
umask a=rx,ug+w umask 002
$ umask 0002
$ umask -S u=rwx,g=rwx,o=rx
umask -- -w
RATIONALESince 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 ... \;
SEE ALSOChapter 2, Shell Command Language, chmod The Base Definitions volume of POSIX.1-2008, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines The System Interfaces volume of POSIX.1-2008, umask()
COPYRIGHTPortions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at www.unix.org/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see www.kernel.org/doc/man-pages/reporting_bugs.html .