Useful Commands

Sing-Box

Enable and start the Sing-Box service:

systemctl daemon-reload && systemctl enable --now sing-boxCode language: Bash (bash)

Update SingBox at least once per week as it is actively developed:

systemctl stop sing-box
go install -v -tags "with_acme with_ech with_quic with_utls with_v2ray_api with_clash_api with_gvisor with_lwip with_grpc with_quic with_wireguard with_ech with_utls with_gvisor with_shadowsocksr" github.com/sagernet/sing-box/cmd/sing-box@dev-next
cp ~/go/bin/sing-box /usr/local/bin/
systemctl start sing-boxCode language: Bash (bash)

Check your Sing-Box version name:

sing-box version -nCode language: Bash (bash)

Check your config.json for errors:

sing-box check -c /etc/sing-box/config.jsonCode language: Bash (bash)

Do not concern yourself with additional spaces, tabs, or formatting errors when editing the config file. Sing-Box can automatically correct the file format. Execute the following command:

sing-box format -wc /etc/sing-box/config.jsonCode language: Bash (bash)

Linux

All my Sing-Box premade config files have the local socks proxy set up to run at port 1080. To check the server connection from your Sing-Box client, use this command:

curl --proxy "socks5h://127.0.0.1:1080" "ifconfig.me"Code language: Bash (bash)

If the output displays the public IP address of your server, you can move forward with connecting other devices to the VPN router gateway.

The journalctl command allows you to view the logs of a specific service on a Linux system. The -xefu options tell it to show all log messages (-x), follow the logs in real-time (-f), show messages from all units (-e), and filter the logs based on the specified unit (in this case, sing-box):

journalctl -xefu sing-boxCode language: Bash (bash)

To use nano to edit a file, open the terminal and type “nano” followed by the name of the file you want to edit. For example, “nano config.json” will open the file “config.json” in nano. Once the file is open in nano, you can use the arrow keys to navigate and make changes to the text.

nano /etc/sing-box/config.jsonCode language: Bash (bash)

To save the changes, press “CTRL + O” and then press “Enter” to confirm the file name. To exit nano, press “CTRL + X“. You will be prompted to save any unsaved changes before exiting.