I. File permissions and directory permissions in Linux
Linux defines 3 access rights, namely R, W, X. where r indicates that the object is readable, w indicates that the object is writable, and X indicates that the object is executable, and that the 3 permissions constitute a set of 3 security levels for the object, respectively, rwx. These 3 security levels are the object's owner, the group to which the object belongs, and other users of the system. File permissions than shown in 1-1
Figure 1-1
second, the Understanding Authority (RWX) the bit weights
RWX3 permissions, each of these permissions represents a bits. where r permission binary is represented as 100, octal is represented as 4;W permission binary representation is 010, octal is represented as 2;r permission binary representation is 001, octal is represented as 1, no permission is represented as---, that is, binary is represented as 000, octal is represented as 0. So the RWX permission can be expressed as 4+2+1 that is, 7,rw-permission is expressed as 4+2+0 that 6,r-x permission means 4+0+1 that is, 5,r--permission is 4, and so on, you can get the permission of the bit weight value representation.
Iii. use of the chmod command
(1) chmod mode dest_file: Changes the permissions of the specified file or directory, where the mode parameter can be set using octal mode or symbol mode.
(2) The CHMOD-R mode dest_file:-r option allows permission changes to be recursively scoped to files and subdirectories.
The following is the use of common symbol mode for permission settings, the following is the format of the specified permissions in symbol mode:
chmod [ugo][[+-w][rwx]] Dest_file
The first set of characters in the symbol pattern defines the object that the permission acts on: U represents the owning person, O represents the group, O represents the other users of the system,
The second set of characters (+) indicates that you want to add permissions based on existing permissions, (-) to remove permissions based on existing permissions, and (=) to set permissions to the following values.
The third set of characters is the permission rwx. As shown below
chmod u+w dest_file: Add w permission to the owner of the target file.
chmod u+wx,g+x,o+w dest_file: Add w permissions to the owner of the target file, add x permission to the owning group, and increase the W privilege for other users of the system.
chmod o-w dest_file: Remove W permissions for other users of the target file.
chmod u=rwx dest_file: This symbol mode gives RWX permissions to the owner regardless of the permissions that the owning person has.
iv. demonstration of effect
First, create a 222.txt file in the temp directory, as shown in the corresponding permission 4-1
Figure 4-1
Next, the symbol mode to the owner of the 222.txt file to increase the X permission, the group to increase the W permissions, other users to increase the X permission, the Linux command is as follows, the effect after the execution of 4-2 shows
1 chmod u+x,g+w222. txt
Figure 4-2
In addition, the octal mode to the owner of the 222.txt file to remove the W permission, the group to remove the W permission, increase the X permission, other users remove the X permission, the Linu command as follows, after the execution of effect 4-3 is shown
1 chmod 554 222. txt
Figure 4-3
I personally think that the symbol mode and octal mode are very useful, symbolic mode is closer to the expression of natural language, octal mode is also very good. In general, however, octal mode is used, since the octal mode is used in the Linux bash script to give permission.
Linux Basics-Rights Management Command chmod