Name

umask

Synopsis

    umask [value]

Print the current value of the file creation mode mask , or set it to value, a three-digit octal code specifying the read-write-execute permissions to be turned off when new files are created. Normally used in .login or .profile. umask is a built-in command in the Bash, Korn, and C shells (see Chapters 4 and 5).

umask number

File permission

Directory permission

0

rw-

rwx

1

rw-

rw-

2

r--

r-x

3

r--

r--

4

-w-

-wx

5

-w-

-w-

6

---

--x

7

---

---

Examples

Turn off write permission for others:

    umask 002                Produces file permission -rw-rw-r--

Turn off all permissions for group and others:

    umask 077                Produces file permission -rw-------

Note that you can omit leading zeroes.

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.