用 apt autoremove 和 apt clean 释放磁盘空间
autoremove 删除不再需要的依赖包,clean 清空 /var/cache/apt/archives 里缓存的 .deb 安装包。
运行 `sudo apt autoremove --purge` 删除孤立软件包(连同配置),再用 `sudo apt clean` 清空包缓存。
01命令
命令
$ sudo apt autoremove --purge && sudo apt clean02作用说明
输入 Y 之前先看 autoremove 列出的清单——如果有你特意安装的包,用 `sudo apt mark manual <包名>` 标记为手动安装。大版本升级后 `apt clean` 释放的空间最多,缓存里的 .deb 有时能到几个 GB;只想删过时版本可以用温和一点的 `apt autoclean`。Fedora 上对应命令是 `sudo dnf autoremove` 和 `sudo dnf clean all`。
03风险
!注意: 确认前先检查 autoremove 清单——旧内核也在里面,删掉会失去备用启动项。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- apt(8) - Linux manual page依据: apt autoremove removes packages that were automatically installed to satisfy dependencies and are no longer needed; apt clean clears the local repository of retrieved package files.
最后验证: 2026-09-17 · 分类: 系统与设置