Skip to Content
教程LinuxSing-Box 使用教程 (Linux)

Sing-Box 使用教程 (Linux)

Sing-Box 是一款功能强大的跨平台代理工具。它支持多种协议(如 Shadowsocks、VMess、Trojan、Hysteria2 等)。


仓库安装

使用仓库安装完之后会自动启动systemd服务

“Debian / APT”

sudo mkdir -p /etc/apt/keyrings && sudo curl -fsSL https://sing-box.app/gpg.key -o /etc/apt/keyrings/sagernet.asc && sudo chmod a+r /etc/apt/keyrings/sagernet.asc && echo ' Types: deb URIs: https://deb.sagernet.org/ Suites: * Components: * Enabled: yes Signed-By: /etc/apt/keyrings/sagernet.asc ' | sudo tee /etc/apt/sources.list.d/sagernet.sources && sudo apt-get update && sudo apt-get install sing-box # or sing-box-beta

“Redhat / DNF 5”

sudo dnf config-manager addrepo --from-repofile=https://sing-box.app/sing-box.repo && sudo dnf install sing-box # or sing-box-beta

“Redhat / DNF 4”

sudo dnf config-manager --add-repo https://sing-box.app/sing-box.repo && sudo dnf -y install dnf-plugins-core && sudo dnf install sing-box # or sing-box-beta

托管安装

类型平台命令链接
AURArch Linux? -S sing-boxAUR package
nixpkgsNixOSnix-env -iA nixos.sing-boxnixpkgs unstable package
HomebrewmacOS / Linuxbrew install sing-boxHomebrew package
APKAlpineapk add sing-boxAlpine Linux Edge package
DEBAOSCapt install sing-boxAOSC package

服务管理

对于带有 ystemd 的 Linux 系统,通常安装已经包含 sing-box 服务, 您可以使用以下命令管理服务:

行动命令
启用sudo systemctl enable sing-box
禁用sudo systemctl disable sing-box
启动sudo systemctl start sing-box
停止sudo systemctl stop sing-box
强行停止sudo systemctl kill sing-box
重新启动sudo systemctl restart sing-box
查看日志sudo journalctl -u sing-box --output cat -e
实时日志sudo journalctl -u sing-box --output cat -f

下载配置文件到systemd里指定的配置路径

默认情况下,sing-box 会从 /etc/sing-box/ 目录读取配置文件。 注意: 一般需要加url参数flag到订阅链接后面,否则下载的配置文件格式不正确,参数值为sing-box

sudo curl -o /etc/sing-box/config.json '<订阅链接>?flag=sing-box'

重新启动sing-box服务

sudo systemctl restart sing-box

查看日志

sudo journalctl -u sing-box -f
Last updated on