chmod command and Umask command

Source: Internet
Author: User

In Linux, in order to facilitate the change of the permissions of the main group, you can use numbers to replace RWX. R=4,w=2,x=1,-=0.

-RWX R-x r--is represented by a number 764.

chmod syntax: chmod [-r] XXX file name (XXX is the number)

Or: chmod u+w g-w o+x

: chmod u=rwx GO=RW

Example: chmod 111.txt

The function of the-r option is cascading changes.

In a Linux system, the default directory permissions are 755, and the default permissions for files are 644

Umask command

In a Linux system, who is the authority for directories and files? This involves umask

Umask syntax: umask xxx (XXX is a number)

View Umask values:

[Email protected] ~]# Umask0022[[email protected] ~]#

You can see that the Umask preset is 0022.


Rules:

    1. If the user creates a normal file, the default condition is only readable and writable, and the maximum is 666 (-rw-rw-rw-).

    2. Users create a directory, the default conditions all permissions are open, that is 777 (DRWXRWXRWX)

The umask value is represented by the default value of the above two rules minus umask values. The umask can be customized.

It is not simple to subtract by numbers.

Example: 777-022 should be rwx rwx rwx minus----w-w-, right is rwx r-x r-x

Why not simply use the number subtraction to calculate permissions? Take a look at this example:

umask=033

The default permissions for files are 666,666-033=633 that is rw--wx-wx, which is actually wrong,

Actually rw-rwx-rw-minus----wx-wx equals rw-r--r--, which is 644.

Umask can be modified in the/ETC/BASHRC, the default, root umask value is 022, and the average user's umask value is 002, because the writable permission is very important.

chmod command and Umask command

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.