Linux has default file, folder permissions umask. Default 777-xxx (folder) 666-xxx (file)
11. View Current User Umask
R (4)--w (2)--x (1)
[Email protected] ~]# umask #查看
0022
[Email protected] ~]#
[Email protected] ~]#
[Email protected] ~]# umask-s #对应umask的权限
U=rwx,g=rx,o=rx
Use
Pre-set permissions (permission masks), when we create a directory or archive, it will have a default permission:
If the user is created as ' archive ' then the default ' no executable (x) item ', that is, only the RW two items, denoted by a number is 666 or letter
–rw-rw-rw-
If the user is created as a ' directory ', the preset is open for all permissions, that is, 777 or letter, because X is related to whether it can enter this directory
D-rwx-rwx-rwx
Umask is related to this default permission. Umask is the "default value of the current user's permission to create a file or directory ."
Usage
We can view the umask default values like this,
# view
$umask # number Form 002 # Some machines may show 4 numbers, we generally use the latter three $umask-s # character forms U=rwx,g=rwx,o=rx
Note that the Um:ask score refers to the permission that the default value needs to be dropped, and the default permissions
Therefore, the above 002 is actually removed the other user's write permission, for the file, that is, the actual permission is 664, namely:
-rw-rw-r-
For the catalog, the actual is 773, namely:
-rwx-rwx-rx
2. Settings
Umask 002
Umask after 3 numbers can be set. To modify the value of the umask for a long time, you can write it into /etc/profile or ~/.profile or ~/.bash_profile .
Examples
Assuming that your umask is 003, what is the Umask case that establishes the file and directory permissions for?
A: Umask is 003, so the permission to take off is--------W, so:
File: (-rw-rw-r-)-(--------wx) =-rw-rw-r--
Catalog: (drwxrwxrwx)-(--------wx) = drwxrwxr--
Reference:
Http://www.cnblogs.com/ezhengnan/p/3670045.html
Default default permissions for Linux under Umask