Do not mislead you with the umask subtraction that has been circulated on the Internet ------- a considerable number of people have gone into misunderstanding.

Source: Internet
Author: User
Don't let umask subtraction spread on the Internet mislead you --------- a considerable number of people have gone into misunderstanding-general Linux technology-Linux technology and application information. The following is a detailed description. Umask is the permission mask. What is the permission mask? Simply put, the corresponding permissions can be masked. The default mask value of the root user is 0022, and the default mask value is 0002.
Three file permissions: Read (r, 4), write (w, 2), run (x, 1). add up to 4 + 2 + 1 = 7
The permission mask is four bits, but usually the last three bits are used, which is the same as what we usually call the permission mask with three bits. we can try the following operations to enable a terminal (tested by a common user ):
$ Touch umask.txt
$ Ls-l
You can see the detailed information of the newly created file umask.txt. Here we mainly show you its permissions:
-Rw-r -- 1 jingjing 0 07-13 11: 11 umask.txt
Note that red indicates the user's operation permission on the file, blue indicates the group's operation permission on the file, and black indicates the operation permission of other users on the file. file Permission 664
Well, I believe this is true in any forum. The key to my topic is as follows:
A lot of online materials are like this:
For example, umask: 002, the created file's permission value is 666 minus 002, and the result is 664. 6: r + w 6: r + w 4: r
What I want to say is that this is just a coincidence! The real principle is as follows:
Because the permission mask value we set here is 002, that is, it only hides the write permissions of other users (w, 2), so the newly created File Permission is 664; however, please try the following command:
$ Umask 033
$ Touch testumask
$ Ls-l
Take a closer look at the file permissions:
-Rw-r -- 1 jingjing 0 07-13 11: 24 testumask
The permission value should be 644, of which 6: r + w 4: r 4: r. not often seen on the Internet 666-033 = 633. why? As I mentioned above, 033 is used to conceal the write (w, 2) and execution permissions (x, 1) of group and other users, and add up to (2 + 1 = 3 ).
For the information I see on the Internet, 90% means that the permission value of the corresponding file is obtained directly by subtraction, but in fact, I think everyone should understand what is going on !!!
: 0) 1

[ This post was last edited by lyq617617]
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.