Contained WithinFind More DocumentationFeatured Support Resources | Download this book in PDF (7229 KB)
umask(1)Name | Synopsis | Description | Options | Operands | OUTPUT | Examples | Environment Variables | Exit Status | Attributes | See Also Name
Synopsis/usr/bin/umask [-S] [mask] shumask [ooo] cshumask [ooo] kshumask [-S] [mask] ksh93umask [-S] [mask] Description
The umask utility sets the file mode creation mask of the current shell execution environment to the value specified by the mask operand. This mask affects 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 does not affect the file mode creation mask of the caller's environment. For this reason, the /usr/bin/umask utility cannot be used to change the umask in an ongoing session. Its usefulness is limited to checking the caller's umask. To change the umask of an ongoing session you must use one of the shell builtins. If the mask operand is not specified, the umask utility writes the value of the invoking process's file mode creation mask to standard output. shThe user file-creation mode mask is set to ooo. The three octal digits refer to read/write/execute permissions for owner, group, and other, respectively (see chmod(1), chmod(2), and umask(2)). The value of each specified digit is subtracted from the corresponding ``digit'' specified by the system for the creation of a file (see creat(2)). For example, umask 022 removes write permission for group and other. Files (and directories) normally created with mode 777 become mode 755. Files (and directories) created with mode 666 become mode 644). cshSee the description above for the Bourne shell (sh)umask built-in. kshThe user file-creation mask is set to mask. mask can either be an octal number or a symbolic value as described in chmod(1). If a symbolic value is given, the new umask value is the complement of the result of applying mask to the complement of the previous umask value. If mask is omitted, the current value of the mask is printed. ksh93umask sets the file creation mask of the current shell execution environment to the value specified by the mask operand. This mask affects the file permission bits of subsequently created files. mask can either be an octal number or a symbolic value as described in chmod(1). If a symbolic value is specified, the new file creation mask is the complement of the result of applying mask to the complement of the current file creation mask. If mask is not specified, umask writes the value of the file creation mask for the current process to standard output. Options
kshThe following option is supported for /usr/bin/umask and umask in ksh: The default output style is unspecified, but will be recognized on a subsequent invocation of umask on the same system as a mask operand to restore the previous file mode creation mask. ksh93Operands
The following operand is supported: OUTPUTWhen the mask operand is not specified, the umask utility will write a message to standard output that can later be used as a umask mask operand. If -S is specified, the message will be in the following format:
where the three values will be combinations of letters from the set {r, w, x}. The presence of a letter will indicate that the corresponding bit is clear in the file mode creation mask. If a mask operand is specified, there will be no output written to standard output. ExamplesExample 1 Using the umask CommandThe examples in this section refer to the /usr/bin/umask utility and the ksh umask builtin. Either of the commands:
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 the current value of the mode mask:
The output format is unspecified, but historical implementations use the obsolescent octal integer mode format.
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:
sets the mode mask so that subsequently created files have their S_IWGRP and S_IWOTH bits cleared. The command:
sets the mode mask so that subsequently created files have all their write bits cleared. Notice 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. Environment VariablesSee environ(5) for descriptions of the following environment variables that affect the execution of umask: LANG, LC_ALL, LC_COLLATELC_CTYPE, LC_MESSAGES, and NLSPATH. Exit Status
The following exit values are returned: AttributesSee attributes(5) for descriptions of the following attributes: /usr/bin/umask, csh, ksh, shksh93See Alsochmod(1), csh(1), ksh(1), ksh93(1), sh(1), chmod(2), creat(2), umask(2), profile(4), attributes(5), environ(5), standards(5) Name | Synopsis | Description | Options | Operands | OUTPUT | Examples | Environment Variables | Exit Status | Attributes | See Also |
|||||||