ubuntu命令行安装clash

  1. 下载

    # X86
    wget https://github.com/doreamon-design/clash/releases/download/v2.0.24/clash_2.0.24_linux_amd64.tar.gz
    # ARM
    wget https://github.com/doreamon-design/clash/releases/download/v2.0.24/clash_2.0.24_linux_arm64.tar.gz
  2. 解压

    tar -vxf clash_2.0.24_linux_arm64.tar.gz
  3. 复制到程序文件

    cp clash /usr/bin/
  4. 创建配置文件

    mkdir -p /etc/clash/
    nano /etc/clash/config.yaml
  5. 下载Country.mmdb

    wget -O /etc/clash/Country.mmdb https://cdn.jsdelivr.net/gh/Dreamacro/maxmind-geoip@release/Country.mmdb
  6. 启动服务

    clash -d /etc/clash/
  7. 设置为系统服务(可选)

    sudo tee /etc/systemd/system/clash.service << EOF
    [Unit]
    Description=Clash Proxy Service
    After=network.target
    
    [Service]
    Type=simple
    User=root
    ExecStart=/usr/bin/clash -d /etc/clash
    Restart=always
    RestartSec=3
    
    [Install]
    WantedBy=multi-user.target
    EOF
  8. 启动并设置开机自启:

    sudo systemctl daemon-reload
    sudo systemctl start clash
    sudo systemctl enable clash
  9. 配置系统代理(可选)

    echo "export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891" >> ~/.bashrc
    source ~/.bashrc

    查看变量

    env | grep -i proxy

    10.安装界面

    cd ~/.config/clash
    wget https://github.com/haishanh/yacd/releases/download/v0.3.7/yacd.tar.xz
    tar xvJf yacd.tar.xz 
    mv public ui
    vim ~/.config/clash/config.yaml
    external-controller: 0.0.0.0:9090
    secret: "123qwe"
    external-ui: "ui"

    11.卸载

    sudo systemctl stop clash
    sudo systemctl disable clash
    sudo rm /etc/systemd/system/clash.service
    sudo rm /usr/bin/clash
    sudo rm /etc/clash -rf
    unset http_proxy https_proxy ftp_proxy
perlong
“ 一天一个新发现 ”
 喜欢文章
1人喜欢
头像