Name

umask — stdin  stdout  - file  -- opt  --help  --version

Synopsis

umask [options] [mask]

The umask command sets or displays your default permission mode for creating files and directories: whether they are readable, writable, and/or executable by yourself, your group, and the world:

umask            Display as octal number
0002
➜ umask -S         Display as characters
u=rwx,g=rwx,o=rx

Your umask specifies permissions to be removed by default from files and directories you create. With a umask value of zero, files get created with mode 666 (rw-rw-rw) and directories with mode 777 (rwxrwxrwx).[12] Any other umask value gets subtracted from these default modes. For example, if you set your umask to 002:

umask 002

your default mode for files will be 666 minus 002, or 664, which is rw-rw-r--. For directories, it will be 777 minus 002, or 775, which is rwx-r-xr-x.

Here are some common values for your umask. Use mask 0022 to give yourself full privileges, and all others read/execute privileges only:

umask 0022touch newfile1 && mkdir dir1ls -ld newfile1 dir1
drwxr-xr-x    2 smith staff     4096 Nov 11 12:25 dir1
-rw-r--r--    1 smith staff        0 Nov 11 12:25 newfile1

Use mask 0002 to give yourself and your default group full privileges, and read/execute to others:

umask 0002touch newfile2 && mkdir dir2ls -ld newfile2 dir2
drwxrwxr-x    2 smith staff     4096 Nov 11 12:26 dir2
-rw-rw-r--    1 smith staff        0 Nov 11 12:26 newfile2

Use mask 0077 to give yourself full privileges with nothing for anyone else:

umask 0077

Get Macintosh Terminal Pocket Guide 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.