Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the umask command of Linux

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report