About umask in Linux

Source: Internet
Author: User
ArticleDirectory
  • What is umask?
  • How to calculate the umask value?

What is the default permission for creating a file? How can I change the default permission?

What is umask?

When we log on to the system and create a file, there is always a default permission. How does this permission come from? This is what umask does. Umask sets the default permission for the user to create files, which is the opposite of CHMOD. umask sets the permission "complement", while chmod sets the File Permission code. Generally, set the umask value in/etc/profile, $ [home]/. bash_profile, or $ [home]/. profile.

How to calculate the umask value?

The umask command allows you to set the default mode when creating a file. Each type of user (file owner, users in the same group, and other users) has a number in the corresponding umask value. For files, the maximum value of this number is 6. The system does not allow you to grant the execution permission when creating a text file. You must use the CHMOD command to add this permission after the creation. Directory allows you to set the execution permission. For the directory, the maximum number of umask numbers is 7.

The command is generally in the form of umask NNN.
Where NNN is set to umask to 000-777.

We only need to remember that u m a s k is to "take" the corresponding bit from the permission. The following table compares umask values with permissions:
Umask file directory
--------------------
0 6 7
1 6 6
2 4 5
3 4 4
4 2 3
5 2 2
6 0 1
7 0 0
--------------------

For example, if the umask value is 022, the default directory permission is 755, and the default file permission is 644.

Related Article

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.