Linux默认的文件权限为666,目录权限为777。可通过umask(掩码)设置不允许的权限。具体如下表:
|
文件
|
目录
|
默认权限
|
666
|
777
|
umask
|
0002
|
0002
|
最终权限
|
664
|
775
|
[stone@localhost ~]$ umask
0002
[stone@localhost ~]$ mkdir file2
[stone@localhost ~]$ touch f2
[stone@localhost ~]$ ll f2 -d file2
-rw-rw-r-- 1 stone stone 0 Feb 16 17:44 f2
drwxrwxr-x 2 stone stone 4096 Feb 16 17:44 file2
[stone@localhost ~]$ rm -r f2 file2
[stone@localhost ~]$ umask 0022
#设置umask值
[stone@localhost ~]$ mkdir file2
[stone@localhost ~]$ touch f2
[stone@localhost ~]$ ll f2 -d file2
-rw-r--r-- 1 stone stone 0 Feb 16 17:55 f2
drwxr-xr-x 2 stone stone 4096 Feb 16 17:55 file2
转载于:https://blog.51cto.com/stonebox/1134196