What is a umask ?

The Umask (User Mask) is a UNIX function that is used to control the permission bitmask applied to newly created files and folders.
The Umask value is subtracted from the default permission value. The resulting value is then assigned as the permission bitmask to the newly created file or folder.

Note : The default permission values are 777 for directories and 666 for files.

Example

A umask of 022 is assigned. A file is created. The default permissions for a file is 666. The umask (022) is then subtracted from the default permission value of 666. This results in a permission set of 644 (-rw-r–r–) being assigned.

[root@server tmp]# umask 022
[root@server tmp]# umask
0022
[root@server tmp]#
[root@server tmp]# touch document.txt
[root@server tmp]# ls -l document.txt
-rw-r–r– 1 root root 0 Jun  5 17:50 document.txt
[root@server tmp]#

Rick Donato

Want to become a Linux expert?

Here is our hand-picked selection of the best courses you can find online:
Linux Mastery course
Linux Administration Bootcamp
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial