Ubuntu系统安装clash-core设置终端科学上网
准备工作:
1.一台Ubuntu系统的服务器 版本:22.04
2.ssh客户端:putty 下载:https://www.chiark.greenend.org.uk/~sgtatham/putty/
3.ssh文件上传软件:WinSCP 下载:https://winscp.net/eng/index.php
4.clash-core : https://github.com/Dreamacro/clash/releases
5.clash节点yaml文件,自行网上查找
下载好clash-core文件和clash节点yaml文件
并用WinSCP把clash-core文件和clash节点yaml文件上传到Ubuntu系统里
打开putty连接到Ubuntu系统
获取Root权限:
sudo -i
进入上传文件的目录:
cd /home/king/Downloads
解压clash-core文件:
gunzip clash-linux-amd64-v1.12.0.gz
给文件权限:
chmod +x clash-linux-amd64-v1.12.0
在opt目录里建立一个名称clash目录:
mkdir /opt/clash
移动clash-core文件到建立的clash目录里:
mv clash-linux-amd64-v1.12.0 /opt/clash
移动clash节点yaml文件到建立的clash目录里:
mv ywJYD4.yaml /opt/clash
进入clash目录:
cd /opt/clash
重命名clash-core文件:
mv clash-linux-amd64-v1.12.0 clash
重命名clash节点文件:
mv ywJYD4.yaml config.yaml
运行clash并指定yaml文件:
./clash -f config.yaml
简化运行方法:
先安装文件编辑软件:
apt install vim
建立clash服务:
vim /etc/systemd/system/clash.service
按键盘 i 进入编辑,插入内容:
[Unit]
Description=clash-core
[Service]
Type=simple
ExecStart=/opt/clash/clash -f /opt/clash/config.yaml
按Esc退出编辑,输入:wq按回车
重新加载配置:
systemctl daemon-reload
启动clash:
systemctl start clash
查看clash运行状态:
systemctl status clash
安装上网软件:
apt install curl
检查终端能否科学上网:
curl -i google.com
手动设置终端科学上网:
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
设置一个终端科学上网的变量:
vim ~/.bashrc
按键盘 i 进入编辑,插入内容:
alias proxy=”export http_proxy=http://127.0.0.1:7890;export https_proxy=http://127.0.0.1:7890;”
alias unproxy=”unset http_proxy;unset https_proxy;”
按Esc退出编辑,输入:wq按回车
编译下变量文件:
source ~/.bashrc
运行unproxy检查科学上网状态:
运行proxy检查科学上网状态:
可视化UI界面:
建立一个名称ui目录:
mkdir ui
进入ui目录:
cd ui
下载ui文件:
wget https://github.com/Dreamacro/clash-dashboard/archive/refs/heads/gh-pages.zip
解压ui文件:
unzip gh-pages.zip
删除压缩包文件:
rm -rf gh-pages.zip
查看文件:
ls
把目录里的文件移动到ui目录:
mv clash-dashboard-gh-pages/* .
返回clash目录:
cd ..
打开配置文件:
vim config.yaml
按键盘 i 进入编辑,插入内容:
external-ui: /opt/clash/ui
按Esc退出编辑,输入:wq按回车
重启clash:
systemctl restart clash
打开浏览器,输入网址:ubuntu系统IP:9090
端口被占用:
列出占用端口的PID:
lsof -i:7890
杀掉占用端口的PID:
kill -9 pid
暂无评论内容