> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/zh/privesc/permissions/linux-permissions-calculator.md).

# Linux 权限计算器

搜索类似以下的八进制模式 `755`, `644`, `600`, `4755`，或类似以下的符号模式 `rwxr-xr-x` 以转换权限并了解其影响。

## 权限查找器

<table data-view="cards" data-full-width="true" data-search="true"><thead><tr><th>八进制</th><th>符号</th><th>含义</th><th>典型用途</th><th>提权风险</th></tr></thead><tbody><tr><td><code>000</code></td><td><code>---------</code></td><td>无权限</td><td>锁定文件</td><td>低</td></tr><tr><td><code>400</code></td><td><code>r--------</code></td><td>所有者只读</td><td>私钥材料</td><td>如果被错误所有者可读，则风险高</td></tr><tr><td><code>600</code></td><td><code>rw-------</code></td><td>所有者读/写</td><td>SSH 密钥、配置、机密信息</td><td>如果所有者是服务账户，则为中等</td></tr><tr><td><code>640</code></td><td><code>rw-r-----</code></td><td>所有者读/写，组可读</td><td>共享服务配置</td><td>如果组暴露机密信息，则风险高</td></tr><tr><td><code>644</code></td><td><code>rw-r--r--</code></td><td>所有者可写，所有人可读</td><td>公共 Web 文件</td><td>对机密文件而言风险高</td></tr><tr><td><code>660</code></td><td><code>rw-rw----</code></td><td>所有者/组可读写</td><td>团队管理的文件</td><td>如果组能编辑特权脚本，则风险高</td></tr><tr><td><code>664</code></td><td><code>rw-rw-r--</code></td><td>所有者/组可写，所有人可读</td><td>协作文件</td><td>中等到高</td></tr><tr><td><code>666</code></td><td><code>rw-rw-rw-</code></td><td>所有人可读写</td><td>很少适合</td><td>对于配置、脚本或认证文件至关重要</td></tr><tr><td><code>700</code></td><td><code>rwx------</code></td><td>仅所有者完全访问</td><td>私有脚本和目录</td><td>如果所有者正确，则风险低</td></tr><tr><td><code>710</code></td><td><code>rwx--x---</code></td><td>所有者完全访问，组可执行</td><td>供组遍历目录</td><td>中等</td></tr><tr><td><code>750</code></td><td><code>rwxr-x---</code></td><td>所有者完全访问，组可读/执行</td><td>服务目录</td><td>如果组范围较广，则为中等</td></tr><tr><td><code>755</code></td><td><code>rwxr-xr-x</code></td><td>所有者可写，所有人可读/执行</td><td>常见二进制文件和 Web 目录</td><td>如果可写所有者被攻破，则风险高</td></tr><tr><td><code>770</code></td><td><code>rwxrwx---</code></td><td>所有者/组完全访问</td><td>共享管理目录</td><td>如果组可被滥用，则风险高</td></tr><tr><td><code>775</code></td><td><code>rwxrwxr-x</code></td><td>所有者/组可写，所有人可读/执行</td><td>共享 Web 目录</td><td>对代码路径风险高</td></tr><tr><td><code>777</code></td><td><code>rwxrwxrwx</code></td><td>所有人完全访问</td><td>仅限临时实验文件</td><td>对脚本、目录、服务、Web 根目录至关重要</td></tr><tr><td><code>1733</code></td><td><code>rwx-wx-wt</code></td><td>带粘滞位的全局可写目录</td><td>上传/投放目录</td><td>中等</td></tr><tr><td><code>1777</code></td><td><code>rwxrwxrwt</code></td><td>全局可写且带粘滞位的目录</td><td><code>/tmp</code></td><td>中等；检查符号链接/竞争条件问题</td></tr><tr><td><code>2755</code></td><td><code>rwxr-sr-x</code></td><td>SGID 可执行文件</td><td>以文件组身份运行</td><td>如果二进制/脚本可被滥用，则风险高</td></tr><tr><td><code>2775</code></td><td><code>rwxrwsr-x</code></td><td>SGID 组可写目录</td><td>共享项目目录</td><td>如果组能控制被执行的文件，则风险高</td></tr><tr><td><code>4755</code></td><td><code>rwsr-xr-x</code></td><td>SUID 可执行文件</td><td>以文件所有者身份运行</td><td>如果由 root 拥有且可利用，则至关重要</td></tr><tr><td><code>4777</code></td><td><code>rwsrwxrwx</code></td><td>SUID 加全局可写</td><td>严重配置错误</td><td>至关重要</td></tr><tr><td><code>6755</code></td><td><code>rwsr-sr-x</code></td><td>SUID 和 SGID 可执行文件</td><td>特权辅助程序</td><td>如果存在用户可控行为，则至关重要</td></tr></tbody></table>

## 数值计算器

| 值 | 权限 | 符号  |
| - | -- | --- |
| 4 | 读  | `r` |
| 2 | 写  | `w` |
| 1 | 执行 | `x` |
| 0 | 无  | `-` |

将每个类别的值相加：

| 八进制数字 | 符号    | 含义       |
| ----- | ----- | -------- |
| `0`   | `---` | 无访问权限    |
| `1`   | `--x` | 仅执行      |
| `2`   | `-w-` | 仅写入      |
| `3`   | `-wx` | 写入并执行    |
| `4`   | `r--` | 仅读       |
| `5`   | `r-x` | 读取并执行    |
| `6`   | `rw-` | 读取并写入    |
| `7`   | `rwx` | 读取、写入、执行 |

## 特殊位

| 八进制前缀 | 位    | 文件含义       | 目录含义                    |
| ----- | ---- | ---------- | ----------------------- |
| `1`   | 粘滞位  | 在文件上很少见    | 用户只能删除自己的文件             |
| `2`   | SGID | 以文件组身份执行   | 新文件继承目录组                |
| `4`   | SUID | 以文件所有者身份执行 | 在大多数 Linux 系统上对目录没有实际意义 |

## 快速命令

```bash
stat -c '%A %a %U %G %n' /path/to/file
find / -perm -4000 -type f 2>/dev/null
find / -perm -2000 -type f 2>/dev/null
find / -writable -type d 2>/dev/null
find / -writable -type f 2>/dev/null
```

## 排查规则

| 发现                            | 优先级  |
| ----------------------------- | ---- |
| 由 root 拥有、名称或路径异常的 SUID 二进制文件 | 至关重要 |
| root 执行的全局可写脚本                | 至关重要 |
| 可写的服务文件或 systemd 单元           | 至关重要 |
| 可写的 cron 目标                   | 至关重要 |
| 全局可写的 Web 根目录                 | 高    |
| 由特权组拥有的组可写文件                  | 高    |
| 可读的机密、备份、密钥或数据库配置             | 高    |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/zh/privesc/permissions/linux-permissions-calculator.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
