Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the umask command of Linux

Shulou Source: shulou.com Published: 2022-06-01 14:00:02 11月17日 Update

This article is about how to use Linux's umask command. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In the linux system, when we create a new file or directory, these new files or directories will have default access, and the umask command is related to the default access to files and directories.

1. Brief introduction to Command

Umask is a built-in command for Shell and is used to set the permission mask when creating a file.

The permission mask consists of three octal digits. After you subtract the permission mask from 777 (octal), you can get the default permissions for the new file. It has the opposite effect as chmod.

two。 Command format umask [- p] [- S] [MODE]

The current permission mask is displayed in octal format if umask is executed separately with no options and parameters.

3. Option description-p [MODE]

Displays or sets the permission mask as an octal number. Displays the current permission mask when MODE is not provided. Is the default option

-S [MODE]

Displays or sets the default permissions for new files in character form. When MODE is not provided, the default permissions for the newly created file are displayed Note: for security reasons, the execution permissions of the file cannot be set through the permission mask and must be modified manually.

4. Common examples

(1) displays the current permission mask.

Umask0022

(2) display the default permissions for new files in character form.

Umask-Su=rwx,g=rx,o=rx

Equal to the octal limit 0777 minus the mask 0022, that is, 0755, displayed in character form as utensil rwx journal gendrx journal obliqurx.

(3) set the permission mask and view it.

# set permission mask umask044 # View permission mask umask044

Thank you for reading! This is the end of the article on "how to use the umask command of Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Permissions files commands octal form characters directories content numbers more formats articles related good practical security parameters commonly used manual effects Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi macOS Xiaomi Shulou Tech Info