1) umask Set the new file created with its default permissions
Umask Total 4 bits, usually with the latter 3 bits. The default Umask value can be viewed using the umask command
1.1) The format of this command is
#umask [-S] [maskexpression] #umask0022 #umask-su=rwx,g=rx,o=rx
1.2) Set Umask value
#umask NNN//Use octal digits (0-7) to assign a value #umask r=rwx,g=,o=//Assign a value with the specified user class #umask +rwx//Use permission letters for all user categories Assign value
2) Calculation of umask and default permission mask
Default File mask is 666
666–umask
If execute permission is present in the reduced result, the octal permission number for the corresponding user class is added to 1, because the file default execution permission is unsafe
default directory mask is 777
777–umask
For Example 1:
umask 002
The newly created file default permissions are:
666–002 = 664
664=rw,rw,w
The newly created directory default permissions are:
777–002 = 775
775=rwx,rwx,rx
For Example 2:
umask 003
The newly created file default permissions are:
666–003 = 663
663=rw,rw,wx
in this case the octal file permission bit for other user classes has Execute permission (2=2+1,1=x), add 1
664=rw,rw,r
3) Use the value set by the umask command, only valid for the current shell process, if you quit or create a new shell process, will not take the current set of Umask value, if we want to make it effective for all users permanently, you can change the/etc/profile file, If you only want to take effect on a single user, you can change the ~/.bash_profile file
4) for the understanding of user rights, please refer to the relevant knowledge of user Rights Management
This article is from the "Whang" blog, make sure to keep this source http://whangh.blog.51cto.com/10054339/1722538
Understanding of Linux Umask