Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ umask(1) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(1)

ksh(1)

sh(1)

chmod(2)

creat(2)

open(2)

umask(2)

file(4)

umask(1)                                                           umask(1)

NAME
     umask - set file-creation mode mask

SYNOPSIS
     umask[ mask]

DESCRIPTION
     The shell built-in umask sets or displays the current user file-
     creation mode mask. This mask defines the access permissions to be
     assigned to all new files and directories which you subsequently
     create in the current shell or in one of its subshells.

     Changes made in the file-creation mode mask remain in effect until a
     new value is set with umask or the shell in which umask was originally
     called is terminated.

     The system administrator can use umask to define the value of the
     file-creation mode mask in the /etc/profile file. Since /etc/profile
     is executed by every login shell, the access permissions set in this
     way are valid for every used logged in on the system (see Example 1).

   Setting permissions with the file-creation mode mask

     When creating files and directories the following permissions are gen-
     erally assigned as base settings [see open(2)]:

     -  rw-rw-rw- to files, i.e. 110110110 in binary notation

     -  rwxrwxrwx to directories, i.e. 111111111 in binary notation.

     umask is only capable of withholding existing permissions from these
     base settings. This means that you cannot use umask to have execute
     permission automatically assigned to new files. You may, however, set
     the appropriate x-bit with the chmod(1) command.

     The file-creation mode mask comprises three octal digits, which are
     specified when calling umask. The permissions they refer to are
     derived as follows:

     1. Convert the digits in the mask to their binary equivalents.

     2. Create the complement to each of these binary numbers, i.e. replace
        the zeros by ones, and ones by zeros.

     3. Add this binary complement to the binary value of the base mode
        setting by logically ANDing the two; the result thus only contains
        ones in positions where both pairs have ones; in all other posi-
        tions it contains zeros.







Page 1                       Reliant UNIX 5.44                Printed 11/98

umask(1)                                                           umask(1)

     Example:

          The file-creation mode mask 022 changes permissions as follows:

          -  Files:

             The base mode setting for files is 110110110.

             1. The binary equivalent of octal 022 is   000010010
             2. The complement of this value is         111101101
             3. AND operation:                          111101101
                                                        110110110
                                                        ---------
                                                        110100100

             The permissions for all newly created files will thus be

             rw-r--r--

          -  Directories:

             The base mode setting for directories is 111111111.

             AND operation:   111101101
                              111111111
                              ---------
                              111101101

             All new directories created will have the permissions

             rwxr-xr-x

OPERANDS
     mask   Three octal digits comprising the file-creation mode mask. This
            mask defines the permissions to be assigned to all new files or
            directories that the user subsequently creates in the current
            shell or in any of its subshells (see Setting permissions with
            the file-creation mode mask above).

            Since umask can only withhold existing permissions from the
            base settings, you cannot use it to have execute permissions
            directly assigned to files, regardless of what you specify for
            mask. Use the command chmod(1) instead.

            In the Korn shell ksh you can specify the file-creation mode
            mask symbolically [see ksh(1)].








Page 2                       Reliant UNIX 5.44                Printed 11/98

umask(1)                                                           umask(1)

            mask not specified:

            umask displays the current user file-creation mode mask. The
            output can be used as input for further umask commands and has
            the following format: 0nnn

            0    Indicates octal notation.

            nnn  The current file-creation mode mask in octal.

            In the Korn shell ksh the file-creation mode mask can also be
            output symbolically [see ksh(1)].

LOCALE
     The LCMESSAGES environment variable governs the language in which
     message texts are displayed. If LCMESSAGES is undefined or is defined
     as the null string, it defaults to the value of LANG. If LANG is like-
     wise undefined or null, the system acts as if it were not internation-
     alized.

     The LCALL environment variable governs the entire locale. LCALL
     takes precedence over all the other environment variables which affect
     internationalization.

EXAMPLES
     Example 1

     The following lines are often included in the /etc/profile file:

     if [ "$USER" != "admin" -a "$USER" != "root" ]
     then
           umask 066
     fi

     Since every login shell executes the /etc/profile file, the file-
     creation mode mask 066 applies to all users except root and admin.

     The following permissions are thus assigned by default:

     -  for new files created: rw-------

     -  for new directories created: rwx--x--x












Page 3                       Reliant UNIX 5.44                Printed 11/98

umask(1)                                                           umask(1)

     Example 2

     Change the file-creation mode mask and display it:

     $ umask 033
     $ > new
     $ mkdir newdir
     $ ls -ld new newdir
     -rw-r--r--   1 anne     other          0   Mar 22 09:49 new
     drwxr--r--   2 anne     other        520   Mar 22 16:40 newdir
     $ umask
     0033

     The output of the ls -ld ... command shows which access permissions
     are assigned to new files and directories when the file-creation mode
     mask has been set to the value 033.

NOTES
     Some differences in behavior may occur when using umask, depending on
     which shell is being used. The possible differences are not described
     specifically.

FILES
     /etc/profile
          File executed by each login shell; used to set a shell environ-
          ment.

          The system administrator normally defines one mask value for
          users without special privileges and one for root in this file.

SEE ALSO
     chmod(1), ksh(1), sh(1), chmod(2), creat(2), open(2), umask(2), pro-
     file(4).





















Page 4                       Reliant UNIX 5.44                Printed 11/98

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026