Ubuntu 终于可以使用clash,不用担心网络问题而使用不了GitHub了,还有个ChatGPT。
1、下载clash
首先是下载最新版本的,访问GitHub:https://github.com/Dreamacro/clash/releases
找到clash-linux-amd64-v*.*.*.gz,找到对应的版本

在Ubuntu使用git clone下载
wget https://github.com/Dreamacro/clash/releases/download/v1.15.1/clash-linux-amd64-v1.15.1.gz
解压压缩包,并给执行权限
gzip -d clash-linux-amd64-v1.15.1.gz
chmod +x clash-linux-amd64-v1.15.1
移动文件夹到/usr/local/bin/clash目录下面
mv clash-linux-amd64-v1.15.1 /usr/local/bin/clash
2、查看是否安装成功
查看clash版本
xxx@xxx:/usr/local/bin# clash -v
Clash v1.15.1 linux amd64 with go1.20.3 Sun Apr 16 13:17:49 UTC 2023
3、配置文件
首先查看配置文件位置
xxx@xxx:/home/saiita# ls $HOME/.config/clash/config.yaml
/root/.config/clash/config.yaml
如果没有配置文件可以先执行clash,自动化生成文件
xxx@xxx:~# clash
INFO[0000] Can't find config, create a initial config file
INFO[0000] Can't find MMDB, start download
INFO[0000] Mixed(http+socks) proxy listening at: 127.0.0.1:7890
详细的配置文件获取,可以使用狮子云的魔法工具,Windows 上下载clash客户端,然后在客户端上获取详情的配置

点击编辑-Edit

这里面就是Clash For Ubuntu 的相关配置项

把里面的配置项复制到Ubuntu里的config.yaml。如果直接复制进去,可能会有排版问题。可以查看这篇文章:Vim中排版脚本代码的技巧
4、运行clash
在Ubuntu终端输入clash,就可以运行clash了。
5、配置Ubuntu网络代理
使用vim打开~/.bashrc文件
在配置文件最下面加入
#fi
export PATH=$PATH:/usr/local/bin
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890
然后就可以ping下网址,是否已经生效
6、配置clash开启自动启动
打开/etc/systemd/system/clash.service,添加一个clash.service文件夹
填入下面的配置项
[Unit]
Description=Clash - A rule-based tunnel in Go
Documentation=https://github.com/Dreamacro/clash/wiki
[Service]
OOMScoreAdjust=-1000
ExecStart=/usr/local/bin/clash -f /root/.config/clash/config.yaml
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
设置开机自动启动
systemctl enable clash
启动clash
systemctl start clash
重启clash
systemctl restart clash
停止clash
systemctl stop clash
查看状态
systemctl status clash
运行中的状态
root@ITX:/usr/local/bin# systemctl status clash
● clash.service - Clash - A rule-based tunnel in Go
Loaded: loaded (/etc/systemd/system/clash.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-05-03 20:18:27 CST; 5s ago
Docs: https://github.com/Dreamacro/clash/wiki
Main PID: 1794860 (clash)
Tasks: 13 (limit: 28442)
Memory: 8.1M
CPU: 164ms
CGroup: /system.slice/clash.service
└─1794860 /usr/local/bin/clash -f /root/.config/clash/config.yaml
5月 03 20:18:27 ITX systemd[1]: Started Clash - A rule-based tunnel in Go.
5月 03 20:18:27 ITX clash[1794860]: time="2023-05-03T20:18:27+08:00" level=info msg="Start initial compatible provider 故障转移"
5月 03 20:18:27 ITX clash[1794860]: time="2023-05-03T20:18:27+08:00" level=info msg="Start initial compatible provider 自动选择"
5月 03 20:18:27 ITX clash[1794860]: time="2023-05-03T20:18:27+08:00" level=info msg="Start initial compatible provider 狮子云-设计师专业工具"
5月 03 20:18:27 ITX clash[1794860]: time="2023-05-03T20:18:27+08:00" level=info msg="RESTful API listening at: 127.0.0.1:9090"
5月 03 20:18:27 ITX clash[1794860]: time="2023-05-03T20:18:27+08:00" level=info msg="Mixed(http+socks) proxy listening at: [::]:7890"
就可以上网了,以后不用担心Ubuntu更新源会出现连接超时的问题了,还有就是树莓派的openwrt不知道怎么配置,配置了好几次,都没成功。还有就是Clash For Windows 也不知道怎么用,从来都没在Windows上使用clash
使用clash-linux-amd64-v1.8.0.gz版本的吧,最新版本的启动后运行失败
root@ITX:/usr/local/bin# systemctl status clash
● clash.service - Clash - A rule-based tunnel in Go
Loaded: loaded (/etc/systemd/system/clash.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2023-05-03 20:12:33 CST; 2s ago
Docs: https://github.com/Dreamacro/clash/wiki
Process: 1785262 ExecStart=/usr/local/bin/clash -f /root/.config/clash/config.yaml (code=exited, status=1/FAILURE)
Main PID: 1785262 (code=exited, status=1/FAILURE)
CPU: 3ms
本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可。
暂无评论
要发表评论,您必须先 登录