//umask is mixed with Linux OS to provide security
//Default umask for Super user
[root@centos ~]# umask
0022 //which means no one will have the write permission except user
[root@centos ~]# touch testfile
[root@centos ~]# mkdir testdir
[root@centos ~]# ls -lah | grep test
drwxr-xr-x 2 root root 6 Aug 19 00:36 testdir
-rw-r--r-- 1 root root 0 Aug 19 00:36 testfile
-----------------
//Default umask for Normal user
[boobalan@centos ~]$ umask
0002 //which means remove write permission from only others
[boobalan@centos ~]$ touch testfileuser
[boobalan@centos ~]$ mkdir testdiruser
[boobalan@centos ~]$ ls -lah | grep test
drwxrwxr-x 2 boobalan boobalan 6 Aug 19 00:42 testdiruser
-rw-rw-r-- 1 boobalan boobalan 0 Aug 19 00:42 testfileuser
-------------
//example how the value 0022 is become
so the value to is going to remove the permission, usually 2 is for write permission hence reduce the umask value form full permission then will get the actual permission of usmak
full permission of file = 0666 - 0022 = 0644 ->default permission
full permission of dir = 0777 - 0022 = 0755 ->default permission
----------------------
//how to change the umask value
//normal user
[boobalan@centos ~]$ umask
0002
[boobalan@centos ~]$ umask 0022
[boobalan@centos ~]$ umask
0022
//super user
[root@centos boobalan]# umask
0022
[root@centos boobalan]# umask 0002
[root@centos boobalan]# umask
0002
//this is an temporary after reboot the value is changed to default
//To change the umask value as permanent follow below
//there are 3 place where we can set the umask value for permanent mode
1. /etc/profile //it reflect to all users including root
2. /etc/bashrc //it reflect to all user including root
3. /etc/profile.d/umask.sh //this is custom setting all users including root
4. /home/username/.bashrc //it reflect individual user only
//example
[root@centos ~]# cat /etc/profile | grep umask
# By default, we want umask to get set. This sets it for login shell
umask 002
umask 022
[root@centos ~]# cat /etc/bashrc | grep umask
# By default, we want umask to get set. This sets it for non-login shell.
umask 002
umask 022
[root@centos ~]# cat /etc/profile.d/umask.sh
cat: /etc/profile.d/umask.sh: No such file or directory
[root@centos ~]# cat /home/boobalan/.bashrc | grep umask
0 Comments