Home  >  Article  >  Operation and Maintenance  >  What do Unix and Linux file permissions mean?

What do Unix and Linux file permissions mean?

WBOY
WBOYforward
2023-05-17 19:13:041219browse

File Permissions

USER##S_IWUSR##S_IXUSR2WRITE 1EXEC Other users write2WRITE # #S_IXOTHchmod 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;
}

##st_mode

Meaning


Octal value


English note


##S_IRUSR

## User Read


4


READ

User writes


2


WRITE

USER

User execution

1

##EXEC

USER

S_IRGRP

Group Reading

4


READ

GROUP

##S_IWGRP

Group Write


GROUP


S_IXGRP

Group execution


GROUP


##S_IROTH

Read by other users

4

##READ

OTHER

##S_IWOTH



OTHER

Other users execute


##1

# #EXEC
OTHER

This also corresponds to our common
Result:

S_IRUSR, S_IWUSR, S_IRGRP, S_IROTH=400, 200, 40, 4, (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)=644

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete