The Umask function in Linux is used primarily to mask access permission that is not appropriate for new files or directories when creating new files or directories.
There are 9 kinds of access permission for files, respectively: rwxrwxrwx
They represent: User Read user Write user Execute Group read Group write group perform other read other write other execution
The rules for shielding are as follows:
1. No matter how much the shielding code is,
• The newly created file does not have permission to execute by default.
• The newly created directory has executable permission by default.
2. The format of the screen code is octal format, a total of three octal number. You can set the following 002 or 022 or ...
3. Each of these octal is represented by three digits, namely, read-write execution
4 2 1
For example, 002 is represented in binary as: 0 0 0--0 0 0--0 1 0
4 2 1 4 2 1 4 2 1
4. The resulting file is the umask value of the allowable permission, namely
For file: ~002 = 664 (the access rights that the newly created file should have)
For directory: ~002 = 775 (The access rights that the newly created directory should have)