DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

umask(C)


umask -- get or set file-creation mode mask

Syntax

umask [ -S ] [ mask ]

Description

The user file-creation mode mask is set to mask. The mask affects the file permission bits of files which are subsequently created. mask may be specified in either absolute mode (an octal integer) or in symbolic mode (a string) as for chmod(C).

If mask is an octal integer, only the low-order 9 bits are used. The value of each specified digit is ``subtracted'' from the corresponding ``digit'' in the new files' permissions (see umask(S) or creat(S) for details).

Every octal digit can be represented by three bits; an octal integer used by umask consists of three digits (or nine bits). Each bit corresponds to a permission which may be applied to a file when it is created, and each octal digit corresponds to one of the ``owner'', ``group'' and ``other'' permission groups. Thus, the octal digit for ``owner'' permissions can contain any combination of three bits, which are used to set ``read'', ``write'' and ``execute'' permissions.

The value of each specified digit is subtracted from the corresponding digit specified by the system for the creation of any file (see umask(S) or creat(S)).

If a given mode bit in mask has the value ``1'', then that permission will be removed from the file; if the mode bit has the value ``0'', it has no effect.

For example, umask 022 removes group and others write permission (files normally created with mode 777 become mode 755; files created with mode 666 become mode 644).

If mask is a symbolic mode string the new value of the file mode creation mask is the logical complement of the file specified permission bits.

If you omit the mask operand, the shell prints the current value of the mask. By default, the shell prints the mask in octal form; specifying the -S option outputs the mask in symbolic form.

umask is built into csh, ksh, and sh.

Examples

Both the following commands set the mode mask so that created files will have all the permission bits for ``other'' clear, and the write, execute bits set for ``group''. Other permission bits are not affected.

umask u=rwx,g=r,o=
umask 037

The following command sets the mask to clear the execute bits for all files created subsequently:

umask -- -x

Note that the ``--'' is necessary to prevent the shell interpreting -x as an option.

See also

chmod(C), chmod(S), creat(S), csh(C), sh(C), umask(S)

Standards conformance

umask is conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003