umask Command
Purpose
Displays or sets the file mode creation mask.
Syntax
umask [ -S ] [ Mask ]
Description
If the Mask parameter is not specified, the umask command displays to standard output the file mode creation mask of the current shell environment. If you specify the Mask parameter using a three-digit octal number or symbolic code, the umask command sets the file creation mask of the current shell execution environment. The bits set in the file creation mask are used to clear the corresponding bits requested by an application or command when creating a file.
The chmod command describes how to use the symbolic and numeric codes to set permissions.
The -S flag produces symbolic output. If the flag is not specified, the default output format is octal.
If the /usr/bin/umask command is called in a subshell or separate command execution environment, it does not affect the file mode creation mask of the caller's environment. This would be the case in the following example:
(umask 002)
nohup umask ...
find . -exec umask ... \;
Flags
Item | Description |
---|---|
-S | Produces symbolic output. |
Exit Status
The following exit values are returned:
Item | Description |
---|---|
0 | The file mode creation mask was successfully changed, or no Mask parameter was supplied. |
>0 | An error occurred. |
Examples
- To set the mode
mask so that subsequently created files have their S_IWOTH bit
cleared, enter either:
ORumask a=rx,ug+w
After setting the mode mask, display the current values of the mode mask by entering:umask 002
The screen displays the following value:umask
02
- To produce symbolic
output, enter:
The screen displays the following values:umask -S
u=rwx,g=rwx,o=rx
- Either numeric or
symbol output can be used as the Mask parameter to a subsequent
invocation of the umask command. Assume the mode mask is set
as shown in example 2. To set the mode mask so that subsequently created
files have their S_IWGRP and S_IWOTH bits cleared, enter:
umask g-w
- To set the mode
mask so that subsequently created files have all their write bits
cleared, enter:
umask -- -w
Note: The -r, -w, and -x Mask parameter values (or anything beginning with a hyphen) must be preceded by — (double hyphen, no space between) to keep it from being interpreted as an option.
Files
Item | Description |
---|---|
/usr/bin/ksh | Contains the Korn shell umask built-in command. |
/usr/bin/umask | Contains the umask command. |