CentOS chmod command
The centos permission is represented by 9 characters, rwx
R indicates read permission, w indicates write permission, and x indicates execution permission.-indicates no permission.
Each of the nine characters is a group of three characters, which are divided into three groups.
The first group indicates the permissions of the Creator;
The second group indicates the permissions of the group where the creator is located;
The third group indicates the permissions of others;
Permission range:
U: the current user of the directory or file
G: current group of directories or files
O: users or groups except the current users or groups of directories or files
A: All users and groups
Permission code:
R: Read Permission, represented by number 4
W: Write Permission, represented by number 2
X: Execution permission, represented by number 1
-: Delete permission, represented by a number 0
S: special permissions
Permissions can also be represented by numbers. Rwx is represented as 4 + 2 + 1 = 7 in numbers.
The default permission for creating a new file is 644; the default permission for creating a new folder is 755.
Command parameters:
Required parameters:
-C report processing information when a change occurs
-F the error message is not output.
-R processes the specified directory and all files in its subdirectories.
-V displays detailed processing information during running
Select parameters:
-- Reference = <directory or File> is set to have the same permissions for the specified directory or file.
-- Version: displays version information.
<Permission range> + <permission settings> grant specified permissions to directories or files within the permission range.
<Permission range>-<permission settings> Delete the specified permission for a directory or file in the permission range
<Permission range> = <permission settings> set the permission for directories or files within the permission range to the specified value.
The correspondence between numbers and characters is as follows:
R = 4, w = 2, x = 1
If you want the rwx attribute, 4 + 2 + 1 = 7
If the rw-attribute is required, 4 + 2 = 6;
If you want the r-x attribute, 4 + 1 = 7.
Command chmod: Modify permissions. The three groups are represented by u, g, and o respectively. grant permissions to "+" and remove permissions to "-".
Chmod u + x f1 // indicates that the creator of file f1 increases the execution permission.
Chmod o-r f1 // indicates that the other person in file f1 has no read permission.