在 Debian 系统中,“重置缓存”通常指清理包管理器的缓存(APT 缓存),或重置 DNS/系统缓存。下面按常见场景分别说明。
.deb 包缓存APT 会把下载的软件包保存在 /var/cache/apt/archives/。
sudo apt clean
作用:
/var/cache/apt/archives/ 下的所有 .deb 文件sudo apt autoclean
作用:
apt clean 更安全sudo apt autoremove
作用:
✅ 通常建议一起执行:
sudo apt clean
sudo apt autoclean
sudo apt autoremove
如果你是想重新拉取软件源索引(不是删除 .deb 文件):
sudo apt update
如果怀疑索引损坏,可先删除再更新:
sudo rm -rf /var/lib/apt/lists/*
sudo apt update
⚠️ 这是安全操作,APT 会重新生成索引。
Debian 默认 没有系统级 DNS 缓存,但如果你使用了以下服务:
sudo systemd-resolve --flush-caches
验证:
sudo systemd-resolve --statistics
sudo systemctl restart dnsmasq
⚠️ 生产环境慎用
sudo sync
sudo echo 3 > /proc/sys/vm/drop_caches
解释:
| 目的 | 命令 |
|---|---|
| 清理 APT 下载缓存 | sudo apt clean |
| 清理过期缓存 | sudo apt autoclean |
| 删除无用依赖 | sudo apt autoremove |
| 重置软件源索引 | sudo apt update |
| 重置 DNS 缓存 | sudo systemd-resolve --flush-caches |
如果你指的是 Docker / apt-proxy / nginx / 浏览器 / 桌面环境缓存,可以告诉我具体场景,我可以给你更精确的命令。