Linux File Permission viewing and modification command chmod
View Permissions
Linux File Access Permissions are divided into three types: readable, writable, and executable.
Run the ls-l command, for example:
Ls-l
Display
-Rwxr-xr-x 1 root 6444 09-22 shmwrite
-Rw-r -- 1 root 1443 09-22 shmwrite. c
Drwxr-xr-x 2 root 4096 09-22 test
The first character represents the file type. D indicates a directory.-indicates a non-directory.
Next, each three characters is a group of permissions, which are divided into three groups, which represent the owner permissions, the same group of user permissions, and other user permissions.
The three characters of each group of permissions indicate whether the permissions are readable, writable, and executable.
R indicates that you have read permission.
W indicates that you have the write permission.
X indicates that you have the executable permission.
-This permission is not granted.
You can run the chmod command to modify the File Permission.
For example:
Chmod 754 test
4 indicates read permission, 2 indicates write permission, and 1 indicates execution permission.
7 = 4 + 2 + 1, indicating that you have the permission to read, write, and execute
5 = 4 + 1, indicating that the account has the permission to read and execute but does not have the write permission
0 indicates that you do not have any permissions.
And so on, why do and 1 represent read and write permissions, rather than other numbers?
We know that the bottom layer of the computer is binary, that is, 0, 1. To indicate the read and write permissions of a file, the underlying layer only needs one byte, that is, eight digits.
If the number of digits from the right is 1, it indicates that the user has read permission. If the number of digits is 1, the user has write permission. If the number of digits is 1, the user has executable permission. If the value is 0, no permission is granted.
That is, convert the binary value to decimal, 0000 0100 = 4, 0000 0010 = 2, 0000 0001 = 1. That is, 4, 2, and 1 indicate that the corresponding binary bit is 1, that is, they have the corresponding permissions. This is also the reason for the above question. In this way, it is easier for everyone to remember the meaning of these numbers.