The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

umask - get or set the file mode creation mask

 SYNOPSIS



umask [-S][mask]

 DESCRIPTION

The umask utility will set the file mode creation mask of the current shell execution environment (see Shell Execution Environment ) to the value specified by the mask operand. This mask will 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 ... \;

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

If the mask operand is not specified, the umask utility will write to standard output the value of the invoking process's file mode creation mask.

 OPTIONS

The umask utility supports the XBD specification, Utility Syntax Guidelines  .

The following option is supported:

-S
Produce symbolic output.

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

 OPERANDS

The following operand is supported:
mask
A string specifying the new file mode creation mask. The string is treated in the same way as the mode operand described in the the EXTENDED DESCRIPTION section for chmod. For a symbolic_mode value, the new value of the file mode creation mask will 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 "-" will be interpreted relative to the current file mode creation mask; "+" will cause the bits for the indicated permissions to be cleared in the mask; "-" will 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 will be set in the file mode creation mask. The file mode creation mask will be set to the resulting numeric value. The default output of a prior invocation of umask on the same system with no operand will also be recognised as a mask operand. The use of an operand obtained in this way is not obsolescent, even if it is an octal number.

 STDIN

Not used.

 INPUT FILES

None.

 ENVIRONMENT VARIABLES

The following environment variables affect the execution of umask:
LANG
Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
LC_ALL
If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_CTYPE
Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- 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 catalogues for the processing of LC_MESSAGES .

 ASYNCHRONOUS EVENTS

Default.

 STDOUT

When 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:

"u=%s,g=%s,o=%s\n", <owner permissions>,
<group permissions>,
<other permissions>
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.

 STDERR

Used only for diagnostic messages.

 OUTPUT FILES

None.

 EXTENDED DESCRIPTION

None.

 EXIT STATUS

The following exit values are returned:
0
The file mode creation mask was successfully changed, or no mask operand was supplied.
>0
An error occurred.

 CONSEQUENCES OF ERRORS

Default.

 APPLICATION USAGE

Since 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.

The references to octal modes are supported because, although they are obsolescent in the ISO/IEC 9945-2:1993 standard, XSI-conformant systems have committed to maintaining them for portable applications until further notice.

 EXAMPLES

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 S_IWGRP, 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.

 FUTURE DIRECTIONS

None.

 SEE ALSO

chmod, the XSH specification description of umask().

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]