========================================================== ==========
This article isHeyuanhuiOriginal
Make sure that the original author information and original links of this article are complete and retained!
NN: khler
E-mail:Khler@163.com
QQ: 23381103
MSN:Pragmac@hotmail.com
========================================================== ==========
In Linux, the LS command is used to list all files in the specified directory. If the '-l' parameter is added, the Operation permissions of all files/folders are listed as follows:
Hyh @ hyh-Ubuntu :~ $ LS-l
Total 96804
-RW-r -- 1 hyh 0 2011-01-30 13:46 AAA. FD
-Rwxrw-RW-1 hyh 7385035 2010-04-15 chntel_linux_ui.tar.gz
-Rwxrw-RW-1 hyh 1373 2010-08-07 client. c
-RW-r -- 1 hyh 0 2011-01-30 13:46 create
Drwxr-XR-x 2 hyh 4096 cutecom
Drwxrwxrwx 2 hyh 4096 cutecom-0.22.0
...
The above mark, for example, "-RW-r --", is the operation permission of the corresponding file.
At the beginning, I was confused about what rwx meant. In fact, it is quite simple to break it down.
To put it simply, there are four parts: Directory tag, current user permission, group user permission, and user permission other than the preceding users, in Linux, 'D', 'R', 'w', and 'X' are used to indicate the 'directory', 'authorization', 'writeable author', and 'executable authorization' respectively '.
1. The first character
The first character indicates whether it is a folder. If yes, It is 'D'; otherwise, it is '-'. It is easy to understand that D is directory. If it is a folder, it is indicated by 'D'. If it is a file, of course it is '-', so you will often see that the first character before the file is '-' When LS-L '-';
2. Current User Permissions
The next three digits indicate the operation permissions of the current user, respectively, rwx. the first digit indicates whether the user has the read permission. If yes, It is 'R'; otherwise, it is '-'. Similarly, the second digit indicates whether you have the write permission. If yes, It is 'W'; otherwise, it is '-'. The third digit indicates whether you have the execution permission. If yes, It is 'x ', that is, 'x' of 'executable'; otherwise, it is '-';
3. Group and other user permissions
The last three digits indicate the permissions of the group, which are used to control all the permissions used by the users in the group. The last three digits indicate the permissions of users other than the preceding users. Also expressed as rwx
4. Why is there another number 76543210?
Because the permissions of all Linux Files are marked with a digital mask, you can use chmod with-R,-W, and-X to increase or decrease permissions, you can also use numbers to control permissions:
0-no permission
1-executable permissions
2-Write Permission
4-Read Permission
In bit:
Bit: 1 1 1
Character: R w x
Number: 4 2 1
After you have the read/write and execution permissions, the permission for this file is 7 = 4 + 2 + 1.
Example:
Before modifying permissions on the AAA. FD file:
Hyh @ hyh-Ubuntu :~ $ LS-l
Total 96804
-RW-r -- 1 hyh 0 2011-01-30 13:46 AAA. FD
After modification with the 755 permission:
Hyh @ hyh-Ubuntu :~ $ Chmod 755 AAA. FD
Hyh @ hyh-Ubuntu :~ $ LS-l
Total 96804
-Rwxr-XR-x 1 hyh 0 2011-01-30 13:46 AAA. FD