1. 程式人生 > >linux基礎命令---umask

linux基礎命令---umask

 

umask

      指定建立檔案時所需要的許可權掩碼,掩碼的執行許可權對於檔案沒有效果。如果模式以數字開頭,則解釋為八進位制數字;否則解釋為符號模式掩碼,類似於chmod(1)所接受的模式掩碼。如果省略模式,則列印掩碼的當前值。

      此命令的適用範圍:RedHat、RHEL、Ubuntu、CentOS、SUSE、openSUSE、Fedora。

 

1、語法

      umask [選項]  mask

 

2、選項列表

選項

說明

-S

以字元方式表示許可權掩碼

-P

顯示當前許可權掩碼

 

3、例項

1)檢視mask,建立目錄

[[email protected] weijie]# umask                       //

不用任何引數,可以檢視掩碼,0022

0022

[[email protected] weijie]# mkdir test               //建立目錄

 [[email protected] weijie]# ll -d test               //

檢視

drwxr-xr-x 2 root root 4096 9  14 10:44 test   //許可權755

2)建立檔案 

[[email protected] weijie]# touch 11.c               //建立檔案

You have new mail in /var/spool/mail/root

[[email protected] weijie]# ll 11.c                  //檢視許可權

-rw-r--r-- 1 root root 0 9  14 10:46 11.c     //許可權644,因為掩碼中的執行許可權,對檔案沒有效果

3)修改掩碼,建立目錄

[[email protected] weijie]# umask 0033              //修改掩碼

[[email protected] weijie]# mkdir test/             //建立目錄

[[email protected] weijie]# ll -d test/             //檢視許可權

drwxr--r-- 2 root root 4096 9  14 10:48 test/           //許可權是744