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:
If the user creates a normal file, the default condition is only readable and writable, and the maximum is 666 (-rw-rw-rw-).
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