“优化 Debian Minimal”通常指在保持轻量的前提下,提升性能、安全性和易用性。下面按实用场景分类给你一套可落地的优化清单,适用于 Debian Minimal(netinst / cloud / container 基础系统)。
apt update && apt upgrade -y
apt install -y sudo curl wget vim net-tools lsof htop tzdata
timedatectl set-timezone Asia/Shanghai
查看服务:
systemctl list-unit-files --type=service | grep enabled
常见可禁:
systemctl disable --now bluetooth
systemctl disable --now avahi-daemon
sysctl vm.swappiness=10
echo "vm.swappiness=10" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6=1" >> /etc/sysctl.conf
sysctl -p
systemddash(默认)bash-completion 等重物journalctl --vacuum-size=50M
限制日志:
mkdir -p /etc/systemd/journald.conf.d
cat > /etc/systemd/journald.conf.d/size.conf <<EOF
SystemMaxUse=50M
EOF
systemctl restart systemd-journald
adduser youruser
usermod -aG sudo youruser
sed -i 's/^#PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
systemctl restart ssh
ssh-keygen
ssh-copy-id user@host
apt install -y ufw
ufw allow 22
ufw enable
apt install --no-install-recommends nginx
apt autoremove --purge
apt clean
lighttpd 代替 nginxbusybox 代替部分 coreutilsdropbear 代替 openssh(嵌入式)debian:slimsysvinit(高级)sudo
ssh
vim
htop
ufw
curl/wget
其余按需装。
如果你能告诉我:
我可以给你定制版优化方案。