Command name: chmod
English intent:CHange the permissions mode of a file
Execute Permissions: All Users
Syntax: chmod [{ugoa}{+-=}{rwx}][file or directory]
[mode=421] [File or directory]
-R Recursive modification
Function: Modify permissions for a directory or file
U:user (owner) G:group (owning group) O:other (others) A:all (All people) r:read (read) w:write (write) x:execute (execution)
As shown, for file Test.txt, the file owner has read and write permissions, the group that the file belongs to, and the other person has read-only permissions.
If you now modify the permissions of the file, modify the permissions to read only to the owner, the group has read and write permissions, the other people do not have any permissions.
General wording: input chmod u-w,g+x,o-r test.txt
Daily writing: chmod 460 test.txt
In Linux rights Management, r corresponds to 4,w corresponding to 2,x corresponding to 1, so 460=r--+ rw-+---=4+ (4+2) +0=460
If you now modify the permissions again, so that all personnel have Execute permissions
chmod a+x test.txt or chmod 571 test.txt
The option-R is actually a recursive modify permission, such as: we use Mkdir-p/tmp/a/b in the directory/TMP to create a directory recursively, and in the A directory to create a B directory, and then directory B under the directory C and file C.txt, then to see the permissions of directory A, A, The permissions for the two directories are the same
So now the permissions of directory A is set to 777, and then observe the directory A, b permissions, you can see the permissions of directory a changed to 777, but directory B has not changed, want to modify both directory A and directory a under the permissions of all directories and files, you have to use the-R to recursively modify permissions.
Input: Chmod-r 777/tmp/a, as a result, the permissions of directory a including all files or directories under directory A are changed to 777.
Note: rwx has different meanings for files and directories
For example: To verify that the root user created a normal file, ordinary users can not delete it? The answer is yes.
The reason that ordinary users can delete files created by the root user is because the file Test.txt is located in the directory where the permissions are 777, that is, the directory/temp for the user grid, is writable, so can delete the file test.txt.
Remember: the prerequisite for deleting a permission is to have write access to the directory where the file resides. The precondition for deleting a file is not to have write permission on the file, and write permission on the file to modify the contents of the file only.
Rights Management commands in Linux-chmod