# 基本权限UGO

文件权限设置： 可以赋于某个用户或组 能够以何种方式 访问某个文件

文件权限管理之： UGO设置基本权限(r、w、x)

```
    rw-r--r--  alice hr  install.log
```

权限对象：

* 属主： u
* 属组：g
* 其他人： o

权限类型：

* 读：r 4
* 写：w 2
* 执行： x 1

## 设置权限

1. 更改文件的属主、属组
2. chown：

```
chown ops.sre file1 //改属主、属组
chown ops file1     //只改属主
chown .ser file1    //只改属组
```

* chgrp：

```
chgrp it file1        //改文件属组
chgrp -R it dir1    //改变目录dir1的属组及其目录下已有文件的属组
```

1. 更改权限
2. 使用符号

```
chmod u+x file1         //属主增加执行
chmod a=rwx file1     //所有人等于读写执行
chmod a=- file1         //所有人没有权限
chmod ug=rw,o=r file1 //属主属组等于读写，其他人只读
```

* 使用数字

```
chmod 644 file1  //给file1 属主读写，属组和其他读的权限
```

## r、w、x权限对文件和目录的意义

| 权限     | 对文件的影响     | 对目录的影响                 |
| ------ | ---------- | ---------------------- |
| r（读取）  | 可以读取文件的内容  | 可以列出目录的内容（文件名）         |
| w（写入）  | 可以更改文件的内容  | 可以创建或删除目录中的任一文件        |
| x（可执行） | 可以作为命令执行文件 | 可以访问目录的内容（取决于目录中文件的权限） |


---

# Agent Instructions: 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:

```
GET https://wiki.clay-wangzhi.com/linux/wen-jian-quan-xian/ji-ben-quan-xian-ugo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
