[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 5

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

-S Produces symbolic output.

Exit Status

The following exit values are returned:

0 The file mode creation mask was successfully changed, or no Mask parameter was supplied.
>0 An error occurred.

Examples

  1. To set the mode mask so that subsequently created files have their S_IWOTH bit cleared, enter either:

    umask a=rx,ug+w

    OR

    umask 002

    After setting the mode mask, display the current values of the mode mask by entering:

    umask

    The screen displays the following value:

    02
  2. To produce symbolic output, enter:

    umask -S

    The screen displays the following values:

    u=rwx,g=rwx,o=rx
  3. 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
  4. 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

/usr/bin/ksh Contains the Korn shell umask built-in command.
/usr/bin/umask Contains the umask command.

Related Information

The bsh command, chmod command, csh command, ksh command.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]