[root@kvm8 ~]# umask --help
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.
參數說明:
-S(Symbolic): 以符號類型顯示權限
[root@kvm8 ~]# su - deyu6
[deyu6@kvm8 ~]$ umask 0022
[deyu6@kvm8 ~]$ touch file1 [deyu6@kvm8 ~]$ mkdir dir1
[deyu6@kvm8 ~]$ ll total 4 drwxr-xr-x. 2 deyu6 deyu6 4096 Apr 29 16:29 dir1 -rw-r--r--. 1 deyu6 deyu6 0 Apr 29 16:29 file1
[deyu6@kvm8 ~]$ umask 0002
[deyu6@kvm8 ~]$ umask -S u=rwx,g=rwx,o=rx
[deyu6@kvm8 ~]$ touch file2 [deyu6@kvm8 ~]$ mkdir dir2
[deyu6@kvm8 ~]$ ll total 8 drwxr-xr-x. 2 deyu6 deyu6 4096 Apr 29 16:29 dir1 drwxrwxr-x. 2 deyu6 deyu6 4096 Apr 29 16:42 dir2 -rw-r--r--. 1 deyu6 deyu6 0 Apr 29 16:29 file1 -rw-rw-r--. 1 deyu6 deyu6 0 Apr 29 16:42 file2
[deyu6@kvm8 ~]$ exit logout [root@kvm8 ~]# su - deyu6 Last login: Thu Oct 27 12:17:24 CST 2022 on pts/0 [deyu6@kvm8 ~]$ umask 0022
[deyu6@kvm8 ~]$ vim .bashrc [deyu6@kvm8 ~]$ tail -1 .bashrc umask 0002
[deyu6@kvm8 ~]$ exit logout [root@kvm8 ~]# su - deyu6 Last login: Thu Oct 27 12:17:51 CST 2022 on pts/0 [deyu6@kvm8 ~]$ umask 0002