记录常用系统管理指令

下载镜像

Debian

if [ -d /etc/apt/mirrors ]; then
    echo "https://mirrors.cernet.edu.cn/debian/" > /etc/apt/mirrors/debian/debian.list
    echo "https://mirrors.cernet.edu.cn/debian-security/" > /etc/apt/mirrors/debian/debian-security.list
else
    sed -i 's/deb.debian.org/mirrors.cernet.edu.cn/g' /etc/apt/sources.list /etc/apt/sources.list.d/debian.sources
    sed -i 's#security.debian.org#mirrors.cernet.edu.cn/debian-security#g' /etc/apt/sources.list /etc/apt/sources.list.d/debian.sources
fi

Ubuntu

TDB

Node

npm config set registry https://registry.npmmirror.com/
pnpm config set registry https://registry.npmmirror.com/

Rust

export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"

清理缓存

Rust

cargo install cargo-cache
cargo cache --autoclean-expensive

Node

npm cache ls
npm cache clean --force
 
pnpm store path
pnpm store prune
 
# run inside folder with package.json
bun pm cache
bun pm cache rm

DotNet

dotnet nuget locals all --list
dotnet nuget locals all --clear

证书管理

OpenWrt
/etc/init.d/acme renew
PVE
systemctl start --no-block pve-daily-update.service
journalctl -u pve-daily-update.service -f
# renew within validity
step ca renew ./cert.pem ./key.pem
# renew after certificate expired
step ca renew ./cert.pem ./key.pem --force
# renew with existing private key but different san
step certificate create "Docker Daemon" --san docker.lan.kokomi.site --san docker.pve.kokomi.site cert.csr --key key.pem --csr
step ca sign cert.csr cert.pem --not-after 8760h

使用到 Cloudflare DNS API Token 的地方

  • PVE, ACME
  • docker,/etc/private/certbot/cloudflare.ini
  • openwrt, /etc/config/acme, /etc/acme/<domain>/<domain>.conf
  • wsl2, ~/.secrets/certbot/cloudflare.ini
  • ddns-go

使用到 Cloudflare Account API Token 的地方

  • RT-AX86U, Cloudflare DDNS Plugin

重启网络

systemctl status  systemd-networkd
systemctl restart systemd-networkd
 
# PVE
ifreload -a

关闭终端后继续运行

# 准备开始运行一个新任务
nohup python train_model.py > my_log.log 2>&1 &
 
# 任务已经跑起来了
$ long_running_script.sh
^Z
[1]+  Stopped                 long_running_script.sh
$ bg
[1]+ long_running_script.sh &
$ disown -h %1
 
# 在脚本内部启动另一个守护进程
setsid your_command > /tmp/log 2>&1 &