Notes on umask system variables in Linux

Source: Internet
Author: User
Tags bit set

Umask is a system variable that, when a file is created, sets a mask for the access rights of the file. You can modify the value of this variable by executing the umask command. It is a value consisting of 3 octal digits. Each number is the result of an octal value of 1, 2, or 4. Their specific meanings are shown in the table below. Three of these numbers correspond to the access rights of the user, group, and other users (other).


Digital Take value Meaning
1 0 Allow any permission to be owned by the owner

4 Prohibit read access to the owner

2 prohibit write permission of the owner

1 Prohibit owner's execution rights
2 0 Allow group any permissions

4 Prohibit read permissions for a group

2 Prohibit Write permissions for groups

1 Prohibit execute permissions for a group
3 0 Allow any permissions for other users

4 Prohibit Read permissions for other users

2 Prohibit write permissions for other users

1 Prohibit execution rights for other users

Understanding: Each octal with a three-bit binary number to represent the----RWX, where, if r=1, the Read permission is forbidden, if w=1, the Write permission is forbidden, if the x=1, then the execution permission is forbidden. This is the exact opposite of the octal usage in the chmod command.


When a file is created through an open or creat call, the mode parameter is compared to the current umask value. The bit set in the mode parameter, if it is also set in the Umask value, is removed from the file's access permissions. As a result, users can fully set their own environment, such as "not allowed to create files that allow other users to have write permissions, even if the program that created the file requires that permission." "This does not make it possible for a program or user to use the chmod command later (or to use a chmod system call in a program) to add write permissions to other users, but it is able to help the user so that they do not have to check and set their access permissions on each new file.

Notes on umask system variables in Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.