> For the complete documentation index, see [llms.txt](https://baozoulin.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://baozoulin.gitbook.io/linux/linux-wen-jian-quan-xian.md).

# Linux 文件权限

[\
![Linux 文件权限](https://morvanzhou.github.io/static/results/linux-basic/03-01-02.png)](https://morvanzhou.github.io/static/results/linux-basic/03-01-02.png)

* **Type**: 很多种 (最常见的&#x662F;**-**&#x4E3A;文件,d为文件夹)
* **User**: 后面跟着的三个空是使用 User 的身份能对这个做什么处理(r能读;w能写;x能执行;-不能完成某个操作).
* **Group**\
  : 一个 **Group** 里可能有一个或多个 **user**, 这些权限的样式和 **User** 一样.
* **Other**\
  : 除了 **User** 和 **Group** 以外人的权限.

## chmod 修改权限

通常的修改形式是

```python
$ chmod [谁][怎么修改] [哪个文件]
```

```python
$ ls -l t1.py
-r--rw-r-- 1 morvan morvan 34 Oct 12 09:51 t1.py
```

\[谁]

* **u**

  : 对于 **User**修改
* **g**

  : 对于 **Group** 修改
* **o**

  : 对于 **Others** 修改
* **a**

  : **(all)** 对于所有人修改

\[怎么修改]

* **+,-,=**: 作用的形式, 加上, 减掉, 等于某些权限
* **r,w,x**或者多个权限一起, 比如**rx**

\[哪个文件]

* 施加操作的文件, 可以为多个

```python
-rw----r-- 1 morvan morvan 80 Oct 12 09:57 t2.py
-rw-rw-r-- 1 morvan morvan 12 Oct 12 09:56 t3
-rwxrw-r-- 1 morvan morvan 55 Oct 13 17:28 t.py

$ chmod u-r t2.py
$ ls -l t2.py
--w----r-- 1 morvan morvan 80 Oct 12 09:57 t2.py

$ chmod g+x-w t3
$ ls -l t3
--w-r-xr-- 1 morvan morvan 12 Oct 12 09:56 t3
```
