Linux-directory, file default properties: Umask use

Source: Internet
Author: User

A permission Mask umask

Umask is chmod matching, a total of 4 (Gid/uid, owner, group rights, other user's rights), but usually use the latter 3, for example, you use chmod 755 file (at this time the permissions of this document is the main read (4) + write (2) + execute (1), The same group and other users have read and write permissions)

The role of two umask

By default the Umask value is 022 (can be viewed with the umask command), at this point you establish the default permissions of the file is 644 (6-0,6-2,6-2), the default permissions for the established directory is 755 (7-0,7-2,7-2), you can verify with Ls-l OH Now you should know the use of umask, it is to control the default permissions, do not make the default files and directories have a full set of

Three modified umask values

Once you know the role of umask, you can modify the value of Umask, for example: Umask 024 The default permissions for files and directories that are created later are 642,753.

Four Save the Umask value to the environment file

To modify the value of the umask for a long time, you can write it into/etc/profile or ~/.profile or ~/.bash_profile.

Do you know what the default attributes will be when you create a new file or directory? Oh! It's about the umask! So what's umask doing? Basically, umask is specifying "the default value of the property when the user is creating the file or directory", so how do you know or set umask? His specified condition is specified in the following way: syntax:


Description: View umask value for direct input umask, and set it? That's right! is umask after three numbers! So how do you specify it? It is mainly related to the file attributes of Linux (that nine properties, R, W, X), and is the example of the relationship with fractions, and the following rules are supplemented:

If the user is set up as "file" then the default "no executable (x) project", that is, only the RW two items, which is the maximum of 666 points

–rw-rw-rw-

If the user is created as a "directory", the default is open for all permissions, which is 777 points, because X is related to whether it can be entered into this directory.

Drwxrwxrwx

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux-directory, file default properties: Umask use

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.