UMASK(1P)
๐ UMASK(1P) โ the POSIX Programmer's Manual page, but make it make sense ๐
okay bestie, sit down, hydrate, and let's talk about umask from the POSIX Programmer's Manual. It's giving "tiny command, huge consequences," fr fr. โจ
๐จ PROLOG ๐จ
This manual page is part of the POSIX Programmer's Manual. Heads up though: the Linux implementation of this interface may differ โ so if you're on Linux, go consult the corresponding Linux manual page for the deets on Linux behavior. Or the interface might just... not be implemented on Linux at all. ๐ No cap.
๐ NAME ๐
umask โ get or set the file mode creation mask. That's the whole vibe. She's simple. She's powerful. She's your new bestie. ๐ซถ
โจ SYNOPSIS โจ
umask [-S] [mask]
That's it. Two little pieces and she can rearrange your entire permission situation. iconic.
๐ธ DESCRIPTION ๐ธ
okay so here's the tea. The umask utility shall set the file mode creation mask of the current shell execution environment (peep Section 2.12, Shell Execution Environment) to whatever value you gave it in the mask operand. ๐
This mask affects the initial value of the file permission bits of files you create afterwards. So like, everything you make after this? Yeah. Masked. ๐
Here's the important part though โ if umask gets called in a subshell or a separate utility execution environment, like one of these:
(umask 002)
nohup umask ...
find . -exec umask ... \;
then it shall not affect the file mode creation mask of the caller's environment. So you can't sneak-changes into your parent shell from inside a subshell, bestie. Not happening. ๐
And if you don't specify the mask operand? Then umask shall write the value of the file mode creation mask of the invoking process to standard output. Just reads it back to you like a lil mirror. ๐ช
๐ OPTIONS ๐
The umask utility shall conform to the Base Definitions volume of POSIX.1โ2017, Section 12.2, Utility Syntax Guidelines. (We love a girl who follows the rules. ๐)
The following option shall be supported:
-Sโ Produce symbolic output. That's it, that's the flag. ๐
Also important: the default output style is unspecified, but it shall be recognized on a subsequent invocation of umask on the same system as a mask operand, so you can restore the previous file mode creation mask. So like, the default format is a mystery but she always knows how to read her own handwriting. ๐ฅ
๐ฆ OPERANDS ๐ฆ
The following operand shall be supported:
maskโ A string specifying the new file mode creation mask. The string is treated in the exact same way as themodeoperand described in the EXTENDED DESCRIPTION section forchmod. (Yes, you have to go readchmodtoo. Sorry babe, cross-referencing is the tax. ๐ญ)
Let's break the mask rules all the way down, no skips:
- For a
symbolic_modevalue, 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 thesymbolic_modestring. Yes, complement. Opposite girl. She's contrarian on purpose. ๐ - In a
symbolic_modevalue, 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.- (Yes, it's backwards from what you'd expect. That's the mask logic, bestie, it's just built different. ๐)
- The interpretation of mode values that specify file mode bits other than the file permission bits is unspecified. So don't come crying when it does something weird. ๐
- 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
umaskon the same system with no operand also shall be recognized as amaskoperand. So she speaks her own language and understands it. ๐
๐ STDIN ๐
Not used. She doesn't want your input here. ๐ โ๏ธ
๐ INPUT FILES ๐
None. Nothing. Zero files. Empty. ๐
๐ ENVIRONMENT VARIABLES ๐
The following environment variables shall affect the execution of umask:
LANGโ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1โ2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLโ If set to a non-empty string value, override the values of all the other internationalization variables. She's the main character, she overrides everybody. ๐LC_CTYPEโ 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).LC_MESSAGESโ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHโ Determine the location of message catalogs for the processing ofLC_MESSAGES.
โก ASYNCHRONOUS EVENTS โก
Default. Nothing special, nothing dramatic. ๐
๐ STDOUT ๐
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. Round trip. Slay. โจ
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 those three values shall be combinations of letters from the set {r, w, x}. And listen โ the presence of a letter shall indicate that the corresponding bit is clear in the file mode creation mask. Yes, presence means clear. I know. Mask logic. It's giving chaos but it's the standard. ๐
If a mask operand is specified, there shall be no output written to standard output. Silence. ๐คซ
๐ญ STDERR ๐ญ
The standard error shall be used only for diagnostic messages. That's her only job here. Don't ask her for more. ๐
๐ OUTPUT FILES ๐
None. Again. Nothing. ๐
๐ง EXTENDED DESCRIPTION ๐ง
None. This section is literally just vibes and empty space. Moving on. ๐
โ EXIT STATUS โ
The following exit values shall be returned:
0โ The file mode creation mask was successfully changed, or nomaskoperand was supplied. Either way, we win. ๐>0โ An error occurred. Something went sideways, bestie. ๐ญ
๐ CONSEQUENCES OF ERRORS ๐
Default.
And jsyk: the following sections are informative. So everything from here down is like... helpful context, not the hard requirement. Still read it though. ๐
๐ APPLICATION USAGE ๐
Since umask affects the current shell execution environment, it is generally provided as a shell regular built-in. So like, she lives inside your shell. She's not some outside contractor. ๐
And here's the big-brain bit: 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. So octal tells her what to mask, symbolic tells her what to leave. Two completely different energies. No cap. ๐ง โจ
๐ฅ EXAMPLES ๐ฅ
okay bestie, examples time. Either of these 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
(Quick note: the output format is unspecified, but historical implementations use the octal integer mode format. So don't @ her if yours looks different. ๐)
$ 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. See? Round trip. Told you. ๐
Assuming the mode mask is set as above, the command:
umask g-w
sets the mode mask so that subsequently created files have their S_IWGRP and S_IWOTH bits cleared. Two birds, one command. ๐ฆ
And the command:
umask -- -w
sets the mode mask so that subsequently created files have all their write bits cleared.
โ ๏ธ Careful bestie: note thatmaskoperands-r,-w,-xor anything beginning with a<hyphen-minus>must be preceded by--to keep it from being interpreted as an option. Otherwise she'll think you're passing a flag and it's gonna get messy. ๐
๐ง RATIONALE ๐ง
Since umask affects the current shell execution environment, it is generally provided as a shell regular built-in. And if it is called in a subshell or separate utility execution environment, like one of these:
(umask 002)
nohup umask ...
find . -exec umask ... \;
then it does not affect the file mode creation mask of the environment of the caller. Same energy as before, just restated in the rationale section. ๐
The description of the historical utility was modified to allow it to use the symbolic modes of chmod. And the -s option used in early proposals was changed to -S because -s could be confused with a symbolic_mode form of mask referring to the S_ISUID and S_ISGID bits. So like, they had to rename her because the lowercase version was causing confusion. glowed up to capital. ๐
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. And 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. So no -o. Never was. Don't go looking. ๐
And here's a lil history tea: 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. So 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. The vibes were adjusted. The standard remains the standard. ๐
๐ฎ FUTURE DIRECTIONS ๐ฎ
None. She's not planning any glow-ups. She's perfect as she is. ๐
๐ SEE ALSO ๐
- Chapter 2, Shell Command Language,
chmod - The Base Definitions volume of POSIX.1โ2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
- The System Interfaces volume of POSIX.1โ2017,
umask()
go read those too, bestie. iykyk. ๐๐
ยฉ๏ธ COPYRIGHT ยฉ๏ธ
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. 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 http://www.opengroup.org/unix/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 https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! ๐ this was brought to you by IEEE/The Open Group, dated 2017, and it's the UMASK(1P) page from the POSIX Programmer's Manual. stay masked, stay iconic, and remember: -- before your hyphen-minus masks or she'll eat your flags. mwah ๐
โจ๐
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms