Introduction
UMASK in a Linux system stands for User Mask. It is the default permission of a file or directory when they are created in your Linux machine.
Most Linux distros have a default value of UMASK is 022.
This article will show you the detail of the UMASK and the way to use it.
Calculate the value of UMASK
The minimum and maximum values of umask for a directory are 000 and 777 respectively. The minimum and maximum values of umask for a file are 000 and 666 respectively. The following table describes some of the common values:
0
1 2 3 4 5 6 7 |
Read, Write & Execute
Read & Write Read & Execute Read Only Write & Execute Write Only Execute Only No Permissions |
---|
To get a better understanding of how to use UMASK in Linux, let’s analyze the following example:
If the value of umask is 077, it means:
0 – the Owner has Read, Write and Execute permission
7 – the Group has no Permissions
7 – Others have no Permissions
$ umask 077
$ mkdir new-folder
$ touch new-file
$ ls -ld new-folder new-file
Get the current umask value
You can get the current value of umask by simply running the command:
$ umask
Another way to set the umask value
Besides the method of using numeric value for umask, you can configure the umask by alphabetic value as:
r – Read
w – Write
x – Execute
u – User ownership
g – Group ownership
o – other ownership
For instance:
$ umask u=rw
$ mkdir test-folder
$ touch file-test
$ ls -ld test-folder file-test
Conclusion
You’ve already gone through the details of how to use UMASK in the Linux system.
Thanks for reading. If you have any concerns, feel free to leave your comment and let me know.