Umask

From Christoph's Personal Wiki
Revision as of 04:16, 14 April 2008 by Christoph (Talk | contribs) (Examples)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

umask (abbreviated from user file creation mode mask) is a function in POSIX environments which affects the default file system mode for newly created files and directories of the current process. It controls which of the file permissions will not be set for any newly created file.

The user file-creation mask is set to mode. If mode begins with a digit, it is interpreted as an octal number; otherwise it is interpreted as a symbolic mode mask similar to that accepted by chmod. If mode is omitted, the current value of the mask is printed.

Options

Note: The return status is 0 if the mode was successfully changed or if no mode argument was supplied, and false otherwise.

  • The -S option causes the mask to be printed in symbolic form; the default output is an octal number.
  • If the -p option is supplied, and mode is omitted, the output is in a form that may be reused as input.

Examples

Note: umask is like the binary NOT of the file permissions you want.'

rwxr-xr-x  #desired file permissions
111101101  #binary file permissions
000010010  #umask
0  2  2    #octal umask

The uid numbers for users are listed in the file /etc/passwd, and the gid numbers are listed in the file /etc/group

  • In /etc/passwd:
champ:x:1001:1001:Christoph Champ:/home/champ:/bin/bash
           |    |
         uid    default gid for user champ
  • In /etc/group:
champ:x:1001:
           |
           gid for group champ

External links