# linux使用clash

### 首先第一步更新系统

```bash
sudo apt-get update
```

### 下载clash

新建一个目录来存放clash

```bash
mkdir clash
```

随后进入目录

```bash
cd clash
```

下载clash

请务必根据自己的系统来灵活调整下载的版本，查询系统详情的命令为uname -a

```bash
wget https://github.com/doreamon-design/clash/releases/download/v2.0.24/clash_2.0.24_linux_amd64.tar.gz
```

解压

```bash
#注意活用tab键补齐
tar -zxvf clash_2.0.24_linux_amd64.tar.gz
```

重命名方便使用

```bash
mv clash_2.0.24_linux_amd64.tar.gz clash
```

赋予clash可执行权限

```bash
chmod 777 clash
```

### 设置配置文件

```bash
#订阅链接请自行替换，另外curl获取的链接一定要加上引号
curl -f "订阅链接" >> config.yaml
```

成功后会在当前目录生成一个config.yaml文件

运行以下命令启动clash

```bash
#运行的时候会使用当前文件夹的config.yaml文件
./clash -d ./
```

命令运行时会自动配置所需文件，需要等待一会儿

设置命令行代理

```bash
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890
```

```bash
#访问下google看看是否有返回
curl "www.google.com"
```

取消命令行代理

```bash
unset http_proxy
unset https_proxy
```

### 在服务器中

可以配合screen命令进行使用

```bash
#下载screen
apt-get install screen

#创建一个screen,clash这个字段可自行替换
screen -S clash
```

现在我们就能在一个单独的窗口运行clash

想要退出screen让它在后台运行，按下Ctrl+A+D即可

```bash
#再回到screen界面
screen -r clash
```

想要删除screen，进入想要删除的screen中，按下Ctrl+D


---

# 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://www.noseeflower.top/ji-shu-za-tan/linux-shi-yong-clash.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.
