在 Debian(及衍生版如 Ubuntu)中,“残留软件”通常指已卸载但配置仍在的包、自动安装但不再需要的依赖,或手动安装后忘记清理的包。下面按场景给你一套清晰、安全的清理方法。
dpkg -l | grep '^rc'
rc 表示:已删除,但配置文件还在apt-get autoremove --dry-run
(先模拟,不真正删除)
dpkg -l | grep '^rc' | awk '{print $2}' | xargs sudo dpkg --purge
或逐个清理:
sudo apt-get purge 包名
sudo apt-get autoremove
sudo apt-get autoclean
说明:
autoremove:删除不再需要的依赖autoclean:清理旧版本的 .deb 缓存sudo apt-get purge 软件名
sudo apt-get autoremove
purge≠remove
remove:保留配置purge:连配置一起删
apt-cache rdepends 包名
apt-mark showmanual
标记为自动:
sudo apt-mark auto 包名
如果你用过 pip / make install / 手动放文件,APT 是管不到的,只能:
/usr/local/checkinstall 替代 make install✅ 删除前先用:
apt-get remove --dry-run 包名
❌ 不要盲目:
apt-get autoremove -y
(可能误删桌面环境组件)
如果你愿意,可以:
dpkg -l | grep '^rc' 的输出我可以帮你精确判断该不该删。