During the interview today, I accidentally dug a hole for myself. When talking about the Linux commands I used, I said a mkdir -m 777 folder name-creating a folder and granting permissions, and then I was asked:
Why does mkdir -m 777 use 777 for folder name granting folder permissions?
In the Linux system, the permissions of files or directories can be divided into three types:
R: 4 readable
W: 2 writable
X: 1 execution
-: corresponding value 0
The numbers 4, 2 and 1 indicate read, write, and execute permissions
rwx = 4 + 2 + 1 = 7 (read and write operation)
rw = 4 + 2 = 6 (read, write, not run)
rx = 4 +1 = 5 (readable, operable, not writable)
So the highest authority is 777: (4+2+1) (4+2+1) (4+2+1);
The first 7: indicates the permissions of the owner of the current file, 7=4+2+1 readable, writable and executable permissions;
The second 7: indicates the permissions of the group (users in the same group) of the current file, 7=4+2+1 readable, writable and executable permissions;
The third 7: indicates the out-of-group permissions of the current file, 7=4+2+1 readable, writable and executable permissions;
So in the same way, 755 and 655 can all indicate corresponding meanings;