本文最后更新于 247 天前,其中的信息可能已经有所发展或是发生改变。
Linux下clash的配置与自启动
下载与配置
下载clash
下载地址:https://github.com/Dreamacro/clash/releases
我下载的是amd64 1.7版本的,下载完成后解压
配置
# 在主目录创建文件夹
cd && sudo mkdir clash
# 移动可执行文件并改名
sudo mv Downloads/clash-linux-amd64-v1.7.0 clash/clash
# 赋予执行权限
cd clash && sudo chmod +x clash
# 运行
sudo ./clash -d .
# 删除默认下载的配置文件
sudo rm config.yaml
# 下载订阅商处提供的配置文件
sudo wget -O config.yml ************订阅商给的链接*************
ps:我用的是GW树洞的订阅,大家如果想用也可以填我的邀请码K5um
,好像会送一块钱?
或者也可以点这个链接注册:https://hello-shudong.com/auth/register?code=K5um
设置代理
在设置中设置网络代理,如图设置完保存
# 再运行
sudo ./clash -d .
成功运行
clash.razord.top 这里可以测速和修改节点代理
设置自启动
因为我比较懒,每次都要开终端敲字填密码真是太麻烦了。。所以想让他开机自启动。
原理
开机后会自动启动 rc-local 服务,rc-local 服务启动后就会自动执行 /etc 目录下的 rc.local 脚本。因为执行脚本的用户是 root 用户,所以不需要密码。
新建 /etc/rc.local 文件
sudo touch /etc/rc.local
sudo chmod +755 /etc/rc.local
在文件中写入以下代码
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
cd clash
sudo ./clash -d .
exit 0
重启试试
老哥,我在设置自启动的时候配置完rc.local文件然后重启,系统就打不开了,错误代码如下:Piix4_SMBus: 000:00:07.3: Host SMBus controller bus not enabled,请问是什么原因呢
我没有遇到过,你可以看看这个https://www.cnblogs.com/zpcoding/p/10760954.html