Umask Basics
What is UMASK
UMASK is known as User Mask which is responsible for deciding permissions on files and directories that gets created.
Default UMASK Values for Files and Directories
In most of the systems you will see a default umask value of 0022 for all files and directories.
How to Calculate Files and Directories Permissions Based on UMASK Value
As you might be aware, base permission of a file is 0666 and base permission of a directory is 0777. Hence final permission of files and directories will get calculated from this base permission values. If umask is set to 0022 in the system, then creating a file and directories will have below permission.
666 with a umask of 022 becomes 644 on any child files
For Files : 0666 - 0022 = 0644
For Directories: 0777 - 0022 = 0755
If umask is set 0032, then creating file and directories will have below permission.
For Files: 0666 - 0032 = 0634
For Directories: 0777 - 0032 = 0745