In Linux, always prompt for settings:
Umask 022
The function is as follows:
Feature Description: Specifies the permission mask that is preset when the file is created.
Syntax: umask [-s][permission Mask]
Supplemental Note: Umask can be used to set the [permission mask]. The [permission mask] is composed of 3 octal digits, and the existing access rights are reduced by the permission mask, so that the default permissions are created when the file is established.
Parameters
-S represents a permission mask in literal form.
File: With octal cardinality 666, that is, there is no X-bit (executable bit) rw-rw-rw-. Execution bits need to be added by the user himself
Example one: Set the file to be generated to rw-r--r--such a permission word appears, that is, the true permission in octal is represented as 644, then 666 radix is reduced by 022,022 is the mask. Use Umask 022.
Note: 033 effects and 221 samples, assuming that the use of 033 mask to set, the real permissions should be 633 is rw-r-x r-x, but the premise that the file does not generate X-bits, so the permissions of the file will eventually appear as rw-r--r--.
Table of Contents: with octal cardinality 777
Example two: Set the directory permissions to be generated to rwxr-xr-x such a permission word appears, that is, the true permission with octal is represented as 755, then the base 777 of the permission word is subtracted, the mask 022. The settings are set using Umask 022.
Summarize:
Master two points, one, the file base is 666, the directory is 777, that is, the file is not set X-bit, the directory can be set X. Second, chmod is set which bit, which is which bit has the authority, and Umask is set which bit, then which bit on does not have the permission.
Instance:
# umask
00
# mkdir Test
# ls-ltr
DRWXRWXRWX 2 root sys (OCT) 11:10 test
# umask 022
# umask
022
# mkdir Test2
# ls-ltr
DRWXRWXRWX 2 root sys (OCT) 11:10 test
Drwxr-xr-x 2 root sys (OCT) 11:11 test2
Vernacular:
In fact, the default permissions are not the same, umask is used to set default permissions.
The role of setting umask in Linux