Linux教程 命令行运行clash

clash (meta)

下载安装包

linux x64下载

curl https://d2.duckgogo.net/mihomo/mihomo-linux-amd64-v1.18.6.gz -o mihomo.gz

or

curl https://d2.duckgogo.net/mihomo/mihomo-linux-amd64-compatible-v1.18.6.gz -o mihomo.gz

linux arm64下载

curl https://d2.duckgogo.net/mihomo/mihomo-linux-arm64-v1.18.6.gz -o mihomo.gz

查看linux系统

uname -m

解压缩

gzip -d mihomo.gz

增加运行权限

chmod +x mihomo

下载clash配置文件

中文引号“替换为英文引号
curl “https://dy.91gzy.top/api/v1/client/subscribe?token=e7e798852d84c90f52c7449f79a6d190&flag=meta” -o config.yaml
(下载你自己的config.yaml)

运行

./mihomo -f config.yaml

设置代理

unset http_proxy
unset https_proxy
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890

检查是否成功

wget www.google.com

以服务方式运行 - systemd

使用以下命令将 Clash 二进制文件复制到 /usr/local/bin/ 文件夹, 配置文件复制到 /etc/mihomo/ 文件夹:

sudo cp mihomo /usr/local/bin/
sudo mkdir /etc/mihomo/
sudo cp config.yaml /etc/mihomo/

创建 systemd 配置文件 /etc/systemd/system/mihomo.service:

[Unit]
Description=mihomo Daemon, Another Clash Kernel.
After=network.target NetworkManager.service systemd-networkd.service iwd.service

[Service]
Type=simple
LimitNPROC=500
LimitNOFILE=1000000
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
Restart=always
ExecStartPre=/usr/bin/sleep 1s
ExecStart=/usr/local/bin/mihomo -d /etc/mihomo
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

启动

systemctl daemon-reload
systemctl enable mihomo
systemctl start mihomo

查看日式

journalctl -u mihomo -o cat -f

启动成功的日志,可通过http://局域网ip:7890或者socks5://局域网ip:7890进行连接

time="2024-06-08T06:48:03.696007163Z" level=info msg="Initial configuration complete, total time: 8319ms"
time="2024-06-08T06:48:03.696814157Z" level=info msg="RESTful API listening at: [::]:9093"
time="2024-06-08T06:48:03.70328271Z" level=info msg="Sniffer is closed"
time="2024-06-08T06:48:03.703315451Z" level=info msg="Use tcp concurrent"
time="2024-06-08T06:48:03.703358798Z" level=info msg="NTP service start, sync system time is false"
time="2024-06-08T06:48:03.796040559Z" level=info msg="System clock is behind NTP time by 1.756498ms"
time="2024-06-08T06:48:03.796466775Z" level=info msg="Mixed(http+socks) proxy listening at: [::]:7890"
time="2024-06-08T06:48:03.80036619Z" level=info msg="Start initial Compatible provider Fallback-备用线路"
time="2024-06-08T06:48:03.800470254Z" level=info msg="Start initial Compatible provider Auto-自动择优"
time="2024-06-08T06:48:03.800589918Z" level=info msg="Start initial Compatible provider 在此组切换线路-SwitchNode"
time="2024-06-08T06:48:03.800944496Z" level=info msg="Start initial Compatible provider default"

sing-box

安装

Debian/Ubuntu

bash <(curl -fsSL https://sing-box.app/deb-install.sh)

Arch Linux

bash <(curl -fsSL https://sing-box.app/arch-install.sh)

拉取配置文件

中文引号“替换为英文引号

curl “https://dy.91gzy.top/api/v1/client/subscribe?token=e7e798852d84c90f52c7449f79a6d190&flag=sing-box” -o config.json

启动

sing-box run -c config.json

以服务方式启动 - systemd

todo

参考链接

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容