下载 Clash Clash Download) 
新建安装目录
下载clash
无法直接用命令下载,需要先下载到本地,再上传到服务器 /opt/clash/ 目录下
 
1 curl -o /opt/clash/clash-linux-amd64-v1.18.0.gz https://down.clash.la/Clash/Core/Releases/clash-linux-amd64-v1.18.0.gz 
解压
1 2 gunzip /opt/clash/clash-linux-amd64-v1.18.0.gz 
重命名
1 mv  /opt/clash/clash-linux-amd64-v1.18.0 /opt/clash/clash
配置并运行Clash 下载配置文件
1 wget -O /opt/clash/config.yaml [订阅链接] 
授权clash
启动clash
启动系统代理 
以下命令适用于Gnome桌面环境
 
1 2 3 4 5 6 7 gsettings set  org.gnome.system.proxy mode 'manual'  gsettings set  org.gnome.system.proxy.http port 7890 gsettings set  org.gnome.system.proxy.http host '127.0.0.1'  gsettings set  org.gnome.system.proxy.socks port 7891 gsettings set  org.gnome.system.proxy.socks host '127.0.0.1'  gsettings set  org.gnome.system.proxy ignore-hosts "['localhost', '127.0.0.0/8', '::1']"  
配置开机启动 新建系统服务文件
1 2 3 4 5 6 7 8 9 10 11 12 13 cat  > /etc/systemd/system/clash.service <<EOF [Unit] Description=clash daemon [Service] Type=simple User=root ExecStart=/opt/clash/clash -d /opt/clash/ Restart=on-failure [Install] WantedBy=multi-user.target EOF 
重载配置
启动Clash
1 systemctl start clash.service 
配置开机启动
1 systemctl enable  clash.service 
配置订阅定时更新 填入以下内容
1 2 3 4 29 6    * * *   root    pgrep clash | xargs kill  -s 9  30 6    * * *   root    mv  /opt/clash/config.yaml /opt/clash/configbackup.yaml  31 6    * * *   root    wget -P /opt/clash/ -O config.yaml https://mojie.best/api/v1/client/subscribe?token=e4510668985ed132db4668feda6ba318&flag=clash 32 6    * * *   root    nohup  /opt/clash/clash -d /opt/clash/ 
重启定时任务使之生效
1 systemctl restart crond.service 
1 https://sub.back2me.cn/sub?target=clash&url=https%3A%2F%2Fmojie.best%2Fapi%2Fv1%2Fclient%2Fsubscribe%3Ftoken%3De4510668985ed132db4668feda6ba318&insert=false  
检查环境变量 1 env  | grep -E 'http_proxy|https_proxy' 
使用代理 1 export  https_proxy=http://127.0.0.1:7890;export  http_proxy=http://127.0.0.1:7890;export  all_proxy=socks5://127.0.0.1:7890