Linux 命令速查
Debian / Ubuntu 上 update 只刷新索引,真正升级要跟上 upgrade。
sudo apt updatesudo apt upgrade -y
# Remove packages that nothing depends on anymoresudo apt autoremove --purge -y管理 systemd 服务
Section titled “管理 systemd 服务”# Status, with the last few log linessystemctl status nginx
# Start now and enable on boot in one gosudo systemctl enable --now nginx
# Reload unit files after editing themsudo systemctl daemon-reload查日志跟着服务走,-f 持续跟随,-n 限制行数:
journalctl -u nginx -n 100 -f磁盘与目录占用
Section titled “磁盘与目录占用”磁盘写满时按这个顺序查:先看整体,再定位到具体目录。
# Overall usage, human readabledf -h
# Largest entries in the current directorydu -h --max-depth=1 . | sort -h | tail -20sudo ufw status verbosesudo ufw allow OpenSSHsudo ufw enable查进程与端口
Section titled “查进程与端口”# Listening sockets with the owning processsudo ss -tulpn
# Find a process by namepgrep -a node安装 Clash Verge(Ubuntu)
Section titled “安装 Clash Verge(Ubuntu)”从 GitHub Releases 下载 deb 包并用 apt 安装,apt 会自动补齐依赖。换版本时只改 URL 里的版本号。
wget https://github.com/Clash-Verge-rev/clash-verge-rev/releases/download/v2.5.2/Clash.Verge_2.5.2_amd64.deb \ -O /tmp/clash-verge.deb && \sudo apt install -y /tmp/clash-verge.deb用 clash.sh 一步到位
Section titled “用 clash.sh 一步到位”上面那条只装程序本体。装完还要开 TUN、改设置、加直连规则、导订阅,这些 clash.sh 都包了。
它必须带子命令,不带参数只会打印用法:
# 全流程:install -> settings -> rules -> sub -> checkCLASH_SUB_URL='https://你的订阅地址' curl -fsSL https://759705.cc/clash.sh | sh -s -- all
# 也可以单独跑某一步curl -fsSL https://759705.cc/clash.sh | sh -s -- installcurl -fsSL https://759705.cc/clash.sh | sh -s -- check| 子命令 | 做什么 |
|---|---|
install |
按 dpkg --print-architecture 选 amd64/arm64 包,apt 安装,然后装 clash-verge-service——TUN 要靠这个 root 服务拿 CAP_NET_ADMIN |
settings |
改写 verge.yaml 的 20 个键,写入 dns_config.yaml 并打开 enable_dns_settings |
rules |
把直连规则装进全局脚本增强 profiles/Script.js,对所有订阅生效 |
sub |
读 CLASH_SUB_URL,先把 app 拉起来再投递 clash:// 深链 |
check |
打印 PASS/FAIL/SKIP 体检表,有 FAIL 时退出码为 1 |
几个必须知道的前提:
settings要求 app 已退出。 app 运行时会用内存态覆写verge.yaml,这时候改文件等于白改。 脚本检测到进程会直接拒绝;想让它替你关掉就加CLASH_FORCE_STOP=1。- TUN 依赖服务。 没装
clash-verge-service时,app 启动会把enable_tun_mode强制改回false。 所以settings检测不到服务就如实写false,不会写一个看着生效实际会被打回的true。 - 规则走脚本增强,不是
Merge.yaml。 merge 是纯深合并,在里面写rules:会整段替换订阅自带的规则;prepend-rules这个键在上游只存在于单元测试里,没有实现。全局Script.js才能真正前插。 - 订阅地址是机密。 只经环境变量传入,不写进任何文件,打印时只保留协议和域名。
# 预览:只打印将要执行的命令,不下载也不改任何文件HUB_DRY_RUN=1 curl -fsSL https://759705.cc/clash.sh | sh -s -- all
# 固定版本,不取 latestCLASH_VERGE_VERSION=2.5.2 curl -fsSL https://759705.cc/clash.sh | sh -s -- install控制接口在 unix socket 上,不是 127.0.0.1:9097——TCP 外部控制器默认是关的,
config.yaml 里那个 9097 是兜底写回的值,不代表真在监听。socket 上不需要鉴权头:
SOCK=/tmp/verge/verge-mihomo.sockcurl -s --unix-socket "$SOCK" http://localhost/versioncurl -s --unix-socket "$SOCK" http://localhost/configs
# 出口是否真的通curl -sS -o /dev/null -w '%{http_code}\n' -m 10 -x http://127.0.0.1:7897 \ https://cp.cloudflare.com/generate_204 # 期望 204
# TUN 服务状态systemctl is-active clash-verge-service && test -S /tmp/verge/clash-verge-service.sock && echo ok配置文件都在 ~/.local/share/io.github.clash-verge-rev.clash-verge-rev/,
其中 clash-verge.yaml 是真正下发给内核的合并产物,config.yaml 不是。