UMASK Specifies the default permissions for the current user when creating a new file or directory, and the user can view the default permissions for the current system files and directories directly using the UMASK directive:
[[email protected] ~]# umask 0022[[email protected] ~]# touch test-1 [[email protected] ~]# mkdir test-11 [[EMA Il protected] ~]# ll total 8-rw-r--r--. 1 root root 0 14:28 tes1-rw-r--r--. 1 root root 0 14:26 test-1 drwxr-xr-x. 2 root root 4096 14:26 test-11
There are two ways to view Umask, one is to enter umask directly, which returns a set of numbers that represent the score of the permission settings, one for the input umask-s, which returns a string of characters representing the user, group, and other user rights.
The default permissions for a file are not executable (x), so the maximum file permissions are-RW-RW-RW, which is 666. The maximum permissions for the directory are drwxrwxrwx, which is 777. Umask The fractional value specified is the permission score that the default permission needs to be dropped.
For example: The value of the current umask is 0022 (the latter three digits represent the general permission) then the permission that needs to be reduced is 022,022 the corresponding permission is----w--w-.
Then the current system default file permissions are: (-rw-rw-rw-)-(-----w--w-) =-rw-r--r--
The new directory permission is: (DRWXRWXRWX)-(d----w--w-) =drwxr-xr-x
(Note: It is not possible to perform mathematical operations directly using the permission values, but only by converting fractions to corresponding symbols for logical operations.) )
If you want to modify the default permissions of the file and directory, you can modify the Umask value to achieve, modify the way umask directly add the permission value you want to lose.
[[email protected] ~]# umask 002[[email protected] ~]# touch Test-2[[email protected] ~]# mkdir test-22[[email protected] ~]# lltotal 12-rw-r--r--. 1 root root 0 14:28 tes1-rw-r--r--. 1 root root 0 14:26 test-1drwxr-xr-x. 2 root root 4096 14:26 test-11-rw-rw-r--. 1 root root 0 14:29 test-2drwxrwxr-x. 2 root root 4096 14:29 test-22
This article is from the "Dark Shun" blog, please make sure to keep this source http://mjal01.blog.51cto.com/12140495/1957084
Umask setting default permissions for Linux system files and directories