在 Debian 系统中释放磁盘空间,可以从定位大文件/目录 → 清理系统垃圾 → 卸载无用软件 → 清理日志/缓存几个方面入手。下面按实用顺序说明。
df -h
查看哪个分区快满了(通常是 / 或 /var)。
查看目录占用空间:
du -h --max-depth=1 /
更直观的工具:
ncdu /
(如未安装:apt install ncdu)
apt clean
或只删旧版本:
apt autoclean
apt autoremove
查看当前内核:
uname -r
查看已安装内核:
dpkg --list | grep linux-image
保留当前和上一个内核,其余可删:
apt remove linux-image-xxxx
du -sh /var/log/*
journalctl --vacuum-time=7d
或限制大小:
journalctl --vacuum-size=100M
truncate -s 0 /var/log/syslog
rm -rf ~/.cache/*
rm -rf /tmp/*
列出已安装软件:
dpkg --get-selections
卸载示例:
apt remove 软件名
apt purge 软件名
docker system prune -a
⚠️ 会删除未使用镜像、容器、网络
find / -type f -size +500M
/var/lib/docker/var/backups/var/crash)如果你愿意,可以:
df -h 和 du -h --max-depth=1 / 的输出我可以帮你精准分析该删什么、不该删什么。