一、linux系统默认umask为022
[root@localhost ~]# umask 0022
查看umask值对应的权限
[root@localhost ~]# umask -S
u=rwx,g=rx,o=rx
022对应的目录权限是:777-022=755 也就是 rwxr-xr-x 对应的文件权限是:666-022=644 也就是rw-r--r--
新建一个文件和目录验证下:
[root@localhost home]# echo "">umask.txt [root@localhost home]# ll umask.txt -rw-r--r-- 1 root root 1 Sep 28 11:28 umask.txt [root@localhost home]#
[root@localhost home]# mkdir umask [root@localhost home]# ll total 4 drwxr-xr-x 2 root root 6 Sep 28 11:29 umask -rw-r--r-- 1 root root 1 Sep 28 11:28 umask.txt
二、设置umask值为077
[root@localhost home]# umask 077 [root@localhost home]# umask 0077 [root@localhost home]# umask -S u=rwx,g=,o= [root@localhost home]#
077对应的目录权限是:777-077=700 也就是 rwx------ 对应的文件权限是:666-077=600 也就是rw-------
新建一个文件和目录验证下:
[root@localhost home]# echo "">umask-077.txt [root@localhost home]# ll umask-077.txt -rw------- 1 root root 1 Sep 28 11:32 umask-077.txt
[root@localhost home]# mkdir umask-077 [root@localhost home]# ll total 8 drwxr-xr-x 2 root root 6 Sep 28 11:29 umask drwx------ 2 root root 6 Sep 28 11:32 umask-077 -rw------- 1 root root 1 Sep 28 11:32 umask-077.txt -rw-r--r-- 1 root root 1 Sep 28 11:28 umask.txt