gpt4 book ai didi

bash - "rw-"文件模式中的第三个符号是什么意思?

转载 作者:行者123 更新时间:2023-11-29 09:30:01 26 4
gpt4 key购买 nike

我无法理解 ls 关于具有 rw- 模式的文件的手册。这是引述:

  1. If r, the file is readable; if -, it is not readable.

  2. If w, the file is writable; if -, it is not writable.

  3. The first of the following that applies:

    S If in the owner permissions, the file is not executable and set-user-ID mode is set. If in the group permissions, the file is not executable and set-group-ID mode is set.

    s If in the owner permissions, the file is executable and set-user-ID mode is set. If in the group permissions, the file is executable and setgroup-ID mode is set.

    x The file is executable or the directory is searchable.

    - The file is neither readable, writable, executable, nor set-user-ID nor set-group-ID mode, nor sticky.

特别是,两个粗体部分似乎相互矛盾:根据第一个,因为模式以 r 开头,文件是可读的,但根据最后一个,文件不可可读。但是,显然情况并非如此。

那么,第三部分关于文件“既不可读,也不可写...”是什么意思?

最佳答案

您的 ls 手册页不是标准的。 POSIX standard man page for ls 没有那样说。以下是相关摘录:

Each field shall have three character positions:

  1. If 'r' , the file is readable; if '-' , the file is not readable.

  2. If 'w' , the file is writable; if '-' , the file is not writable.

  3. The first of the following that applies:

    S

      If in < owner permissions>, the file is not executable and set-user-ID mode is set. If in < group permissions>, the file is not executable and set-group-ID mode is set.

    s

      If in < owner permissions>, the file is executable and set-user-ID mode is set. If in < group permissions>, the file is executable and set-group-ID mode is set.

    T

      If in < other permissions> and the file is a directory, search permission is not granted to others, and the restricted deletion flag is set.

    t

      If in < other permissions> and the file is a directory, search permission is granted to others, and the restricted deletion flag is set.

    x

      The file is executable or the directory is searchable.

    -

      None of the attributes of 'S' , 's' , 'T' , 't' , or 'x' applies.

我认为这更有意义。

类型未在权限位中表示 - 您只查看 ls(1) 报告的内容,而不是它的存储方式。传统上,模式和类型一起使用 32 位,但这取决于文件系统,现在很多文件系统都是 64 位的。权限在 inode 中只有 9 位。

查看 man 2 stat 并搜索 st_models(1) 可能使用的是低级 C 例程。在某些平台上,它还可以作为命令行程序使用 man 1 stat

关于bash - "rw-"文件模式中的第三个符号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31021900/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com