Overview command: chmod, chown, chgrp, umask
I. Introduction
In linux directory file access permissions include read-only, write-only, and execute permissions, corresponds to r, w and x. For a directory file, which include the owner's user type, with the
Group and other users. For each type of user, respectively, using three characters indicate corresponding permission. A complete access to a total of 10 characters, the first left
One represents the directory file types, each of the other three types corresponding to a user's access rights.
For example, access to a file is -rw-r - r--, as follows:
-: Bit 1 indicates the type of the file directory (- indicates a binary file, d indicates a directory, l represents a soft link);
rw-: 2-4 indicates the owner of the file directory permissions;
r--: 5-7 indicates the same group of users permission of the owner of the file directory;
r--: 8-10 indicates a file directory permissions to other users;
Note: Permissions representation "-" indicates no authority, all types of users from the right No. 1 indicates execute permission, the two expressed written permission, No. 3 represents read permission. From Binary
Perspective, three permission (x, w, r) corresponding to a value of x = 2 ^ 0 = 1, w = 2 ^ 1 = 2, r = 2 ^ 2 = 4. At this time, the size of the owner of the rights is 4 + 2 + 0 = 6,
Limited group of users with a full size 0 + 0 + 4 = 4, the size of the rights of other users is 4 + 0 + 0 = 4, the size of the ultimate authority 644.
II. Order
Name command: chmod
English command: change permissions mode of file
Command path: / bin / chmod
Function: to modify the file or directory permissions
Command syntax:
Syntax 1: chmod [-R] [{ugoa} {+ - =} {rwx}] [files or directories];
Syntax 2: chmod [-R] [mode] [directory file];
Parameter Description:
-R: Recursive modification;
mode: authority digital value;
u: the owner of the user; g: belonging group group; o: others other; a: all all;
r: read access read; w: write access write; x: Execute execute permission;
+: Increase the authority; -: delete permissions; =: Delete the original authority, given the current privilege;
Command examples:
Syntax 1: chmod u + x Log2020.log; chmod ug + w, ox Log2020.log
Note: for different user groups append / delete permissions.
Syntax 2: chmod 751 Log2020.log
Note: The owner of the file allocation read, write, and execute permissions, where the group assignment read, execute permissions, assign execute permissions to other users.
Syntax 2: chmod -R 777 directory
Note: To add permissions to all files in a directory and its subdirectories.
-----------------------------------------------------------------------------------------------------------------------
Command name: chown
English command: change file ownership
Command path: / bin / chown
Changes file owner or directory: Command Function
Command syntax: chown [-R] [User: Group] [file or directory]
Parameters: -R: recursively modified
Command examples:
Change the owner and group files: chown root: Log2020.log
chown: root Log2020.log: change the group file
chown root: root Log2020.log: change the owner and group files
-----------------------------------------------------------------------------------------------------------------------
Command name: chgrp
English command: change file group wonership
Command path: / bin / chgrp
Function: to change the file or directory belongs to the group of
Command syntax: chgrp [-R] [User Group] [file or directory]
Parameters: -R: recursively modified
Command Example: chgrp -R group directory
-----------------------------------------------------------------------------------------------------------------------
Command name: umask
Command English: the user file-creation mask
Command path: shell built-in commands
Function: Display, the default settings file mask
Command syntax: umask [-S] [permission mask]
Parameter Description: -S: displays the default file mask to form rwx
Command examples:
umask -S: displays the default mask file to rwx form;
umask 022: Set the default mask;