Linuxumask command quick understanding

Source: Internet
Author: User
The linuxumask command quickly understood how the default permission for creating files in linux was obtained today. I suddenly couldn't remember it. I searched for the umask command and found that the answer was tedious, in fact, this understanding is better! On the linux console, run the umask command. Generally, you will get 0022.
Today, I was asked how the default permission was obtained when I created a file in linux. I suddenly couldn't afford it. I searched for the umask command and found that the answer was tedious. In fact, this is a better understanding!
When you run the umask command on the linux console, you will generally get 0022 yuan. First, you should popularize common sense and create a file without carrying the executable permission x; creating a folder carries the executable permission (otherwise, how can I open the directory?). Based on this common sense, 0022 removes the preceding 0 and returns the inverse of 022 by the file permission flag. As shown in: verify that you have a shell script. Str = "0 1 2 3 4 5 6 7" & for i1 in $ {str}; do for i2 in $ {str}; do for i3 in $ {str }; do umask =$ {i1 }$ {i2 }$ {i3} & umask 0 $ {umask} & touch your umask+.txt & mkdir-p $ {umask}-dir; done; done: this script modifies umask, and then creates the corresponding file and folder. the name of the file is paiyunumaskdemo.txt, and the name of the folder is $ {umask}-dir.
For example, if umask is 777, the created file is 777.txt and the folder name is 777-dir.
In this way, the relationship is clear at a glance.
As shown in:
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.