What do Unix and Linux file permissions mean?

WBOY
Release: 2023-05-17 19:13:04
forward
1222 people have browsed it

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;
}
Copy after login

##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
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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template