#Bash 的 umask 命令
umask [OPTION] MODE
功能
查看或修改 shell 的资源限制。
用户新建文件时的默认权限为
0777减去掩码。
类型
Bash 内置命令。
参数
OPTION选项:-p- 以完整命令的格式打印掩码-S- 以字符串格式打印默认权限
MODE- 掩码;可以表示权限的字符串或八进制数值
#示例
$ umask # 查看掩码
0002
$ umask -p # 打印掩码的命令
umask 0002
$ umask -S # 打印默认权限
u=rwx,g=rwx,o=rx
$ umask 0077 # 设置掩码为 0077,则文件的默认权限为 0700
$ touch file # 新建文件
$ ls -l file # 查看权限
-rw------- 1 planc planc 0 Apr 3 13:48 file
#推荐阅读
#手册
umask: umask [-p] [-S] [mode]
Display or set file mode mask.
Sets the user file-creation mask to MODE. If MODE is omitted, prints
the current value of the mask.
If MODE begins with a digit, it is interpreted as an octal number;
otherwise it is a symbolic mode string like that accepted by chmod(1).
Options:
-p if MODE is omitted, output in a form that may be reused as input
-S makes the output symbolic; otherwise an octal number is output
Exit Status:
Returns success unless MODE is invalid or an invalid option is given.