Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux umask Command

Linux umask Command

Linux Command Reference Linux Command Reference

The Linux umask command specifies the default permission mask applied when files are created.

umask can be used to set the [permission mask]. The [permission mask] consists of three octal digits; subtracting the mask from the current access permissions produces the default permissions for newly created files.

Syntax

umask [-S][权限掩码]

Parameter Description:

-S Represent the permission mask in symbolic (textual) form.

Example

To view the current permission mask with the "umask" command, enter the following command:



$ umask                         #获取当前权限掩码 

After running the command above, the output is as follows:



0022

Next, use the "mkdir" command to create a directory and the "ls" command to get detailed information about it, entering the following commands:



$ mkdir test1                       #创建目录  

$ ls –d –l test1/                   #显示目录的详细信息  

After running the commands above, the details of the newly created directory are shown as follows:



drwxr-xr-x 2 rootlocal rootlocal 4096 2011-9-19 21:46 test1/ 

Note: In the output above, "drwxr-xr-x" corresponds to "777-022=755".

Linux Command Reference Linux Command Reference