在 Ubuntu 中,“清理缓存”通常分几种情况:APT 软件包缓存、系统内存缓存、用户/浏览器缓存、旧内核等。下面按常见场景给你说明。
Ubuntu 用 apt 安装软件时会把 .deb 包存在 /var/cache/apt/archives
sudo apt clean
会清空
/var/cache/apt/archives下所有.deb文件
sudo apt autoclean
sudo apt autoremove
✅ 推荐组合:
sudo apt update
sudo apt autoremove
sudo apt autoclean
sudo apt autoremove --purge
或查看当前内核:
uname -r
不要删当前正在用的内核。
⚠️ 一般不需要手动清理,Linux 会自动管理
free -h
sudo sync
sudo echo 3 > /proc/sys/vm/drop_caches
用户缓存一般在:
~/.cache
清理:
rm -rf ~/.cache/*
rm -rf ~/.cache/thumbnails/*
sudo apt install bleachbit
打开后勾选要清理的项即可。
sudo bleachbit --clean apt.cache thumbnails
docker system prune
或强制清理:
docker system prune -a
如果你能说清楚你是 哪类缓存(磁盘满?卡顿?APT?Docker?浏览器?),我可以给你更精确的命令。