File Permissions
##st_mode
|
Meaning
|
Octal value
|
English note
|
##S_IRUSR
## User Read |
4 |
READ | USER
|
##S_IWUSR
User writes
|
2
|
WRITE USER |
| ##S_IXUSR
User execution |
1
|
##EXEC USER
|
S_IRGRP |
Group Reading
|
4
| READ GROUP
|
##S_IWGRP
|
Group Write
| 2
| WRITE GROUP
|
S_IXGRP
|
Group execution
| 1
| EXEC GROUP
|
##S_IROTH
|
Read by other users
|
4
|
##READ OTHER
|
##S_IWOTH
| Other users write
| 2
| WRITE OTHER
|
# #S_IXOTH
Other users execute |
##1
|
# #EXEC OTHER |
This also corresponds to our common | chmod 755
. The above table can be divided into three groups , the maximum value of each group is 7, indicating read, write and execute permissions. Let’s use C code to see the specific values:
#include <stdio.h>
#include <sys/stat.h>
/*
S_IRUSR: 使用者读权限, READ USER 4
S_IWUSR: 使用者写权限, WRITE USER 2
S_IRGRP: 组用户读权限, READ GROUP 4
S_IROTH: 其他用户读权限, READ OTHER 4
*/
int main(int argc, char const *argv[]) {
printf(
"S_IRUSR, S_IWUSR, S_IRGRP, S_IROTH=%o, %o, %o, %o, (S_IRUSR | S_IWUSR "
"| S_IRGRP | S_IROTH)=%o\n",
S_IRUSR, S_IWUSR, S_IRGRP, S_IROTH,
(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH));
return 0;
}
Copy after login
Result:
S_IRUSR, S_IWUSR, S_IRGRP, S_IROTH=400, 200, 40, 4, (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)=644
Copy after login
The above is the detailed content of What do Unix and Linux file permissions mean?. For more information, please follow other related articles on the PHP Chinese website!