Summary of the use of umask

Source: Internet
Author: User

In Linux, when a new file is created, the system defaults to rw-rw-rw-, the new file does not have permissions for all users, and if you want to add execute permissions for all users, you can use "$CHOMD u+x,g+x,o+x filename" to do so. However, if a source file compilation chain is delivered to a new executable file with the GCC command, it has execute permissions. The system defaults to creating a new directory also has executable permissions.

The use of the umask command can mask the user to create files do not want to have permissions, to achieve the so-called "mask" function, for example, we commonly used 022, the corresponding binary code for 000 010 010 will be the 5th and 8th mask off, then if a new file, then use LS- The l command is listed to see that its permissions are Rw-r--r--, the 5th and 8th bits of the W permission is mask. When the system creates a new file, it gives the default permission rw-rw-rw-, then the umask is reversed, and then the result is in the position of the default authority, which is the essence of umask action.

Here are a few examples:
1, Umask 000
All bits are not masked, new files and folders are default permissions (folder is rwxrwxrwx, file is rw-rw-rw-)
2, Umask 777
Block all Bits
3, Umask u=,g=w,o=
Modify the value of umask so that u and O do not have any permissions, G only W permission, this is umask except fifth, other full screen, should be 111101111, that is 757
4, Umask u=rw,og=x
Modify the value of umask, so that O and g only X permissions, u have RW permissions, then umask should be 001110110, that is 166
5, Umask u=rwx,g=w,o=rwx
Modify the value of umask, so that u have rwx permissions, G has W permissions, O have rwx permissions, this is Umask 000101000, that is 050


You can use the command $umask XXX (octal number) to modify the current umask value, but the next login system will be changed back to 022, if you want to permanently modify, you can change the umask in/etc/profile to the value you want.

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.