在 Debian 系统中,“清除缓存”通常指以下几类情况之一。你可以根据自己的需要选择对应方法:
APT 下载的 .deb 包会缓存在:
/var/cache/apt/archives/
sudo apt clean
会清空
/var/cache/apt/archives/中所有已下载的 deb 包
sudo apt autoclean
sudo apt autoremove
⚠️ 仅建议在必要时使用(如排查性能问题)
free -h
sudo sync && echo 1 | sudo tee /proc/sys/vm/drop_caches
sudo sync && echo 2 | sudo tee /proc/sys/vm/drop_caches
sudo sync && echo 3 | sudo tee /proc/sys/vm/drop_caches
sync用于确保数据写入磁盘,避免数据丢失
常见用户缓存目录:
~/.cache/
du -sh ~/.cache
rm -rf ~/.cache/*
sudo journalctl --vacuum-time=7d
或
sudo journalctl --vacuum-size=100M
sudo systemd-resolve --flush-caches
或(新版本)
sudo resolvectl flush-caches
如果你指的是 某个具体程序的缓存(如 nginx、docker、pip、apt 等),可以告诉我具体场景,我可以给你更精确的命令。