Briefly introduce the use of umask command

Now more and more people use linux system , let me introduce umask command of linux system

A brief introduction to the use of the umask command Brief introduction to the use of the umask command

1. Command Introduction

umask is a  built-in command of  Shell , which is used to set the permission mask when creating files.

The permission mask consists of 3 octal numbers. After subtracting the permission mask from 777 (octal), the default permission of the newly created file can be obtained. It is the opposite of the effect of chmod.

2. Command format

umask [-p] [-S] [MODE]

If you execute umask alone without any options and parameters, the current permission mask will be displayed in octal format.

3. Option description

-p [MODE]

Display or set the authority mask in the form of octal numbers. When MODE is not provided, the current permission mask is displayed. Is the default option

-S [MODE]

Display or set the default permissions of newly created files in characters. When the MODE is not provided, the default permission of the newly created file is displayed.
Note: For security reasons, the execution permission of the file cannot be set by the permission mask and must be modified manually.

4. Common examples

(1) Display the current authority mask.

umask
0022

(2) Display the default permissions of the newly created file in character form.

umask -S 
u = rwx, g = rx, o = rx

It is equal to the octal authority bit 0777 minus the mask 0022, that is, 0755, which is displayed as u=rwx, g=rx, o=rx in character form.

(3) Set the authority mask and view it.

# Set permissions mask 
umask 044 

# View permission mask 
the umask 
044

Guess you like

Origin blog.csdn.net/yaxuan88521/article/details/114727046