Understanding of Linux Umask

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.