Modify the umask value of linux-general Linux technology-Linux technology and application information. For more information, see. Do you know what the default attribute is when you create a new file or directory? Haha! This is related to umask! So what is umask? Basically, umask is to specify the "Default attribute value of the current user when creating a file or directory". How can we know or set umask? Its specified conditions are specified in the following way: Syntax:
[Root @ test root] # umask
0022
[Root @ vbird test] # umask 002 <== followed by three numbers!
[Root @ vbird test] # umask
0002
Note: Check whether the umask value can be set by directly inputting umask? That's right! It is umask followed by three numbers! How can we specify it? It is mainly related to the file attributes of Linux (the nine attributes, r, w, x), and the relationship of scores is used as an example, supplemented by the following rules:
If the user creates an archive, the default "No executable (x) project" is created, that is, only rw projects, that is, up to 666 points.
-- Rw-
If the user creates a "directory", x is enabled for all permissions, that is, 777 points, because x is related to whether the user can access this directory.
Drwxrwxrwx
Then umask specifies the "permission to be removed for this default value !』 Because r, w, and x are 4, 2, and 1 points, so ?? Will the notebook fade? Currency? Meiyun benzna? If you want to get the read and write permissions, that is, the read and write permissions should be removed, but the execution and write permissions should be removed, that is, 3 points. Do you know this? Excuse me, what is 5 points? Haha! Read and execute permissions! As described in the preceding example, because umask is 002, the user and group attributes are not removed, but the others attributes are removed 2 (w ), therefore, when users:
When creating an archive: (-rw -)? (-------- W-) ==>-rw-r --
When creating a directory: (drwxrwxrwx )? (-------- W-) ==> drwxrwxr-x
Don't you believe it? You only need to use touch test and check the file properties of test! So how do you view your current umask? Just issue umask directly! Implementation:
Hey! What is the difference between the attribute and the attribute ?? Why? Cutting shenxi? Est3 666-003 = 663. What is this ?! 663 should be-rw -- wx! How is the above attribute! Haha! He must be particularly stressed here! "Try not to add or subtract numbers !』 It is easy to cause problems similar to the above! You should think like this (-rw-)-(-------- wx) =-rw-r -- that's right! Do you understand? Do not use decimal numbers! If it is sufficient, it can be calculated in binary format. If you do not know it, you can use rwx to calculate it!
From the above example, you can easily find the usage of umask! This umask can be modified in/etc/bashrc! By default, the root umask is set to 022, while the average user is set to 002. Because the write permission is very serious, the default permission will be removed! In addition, because root is important! Therefore, for the sake of security, the write attribute of the same group is removed! This also contributes to security!
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