移除软件包
作为日常系统维护和安全加固的一部分,有时需要移除不再需要的软件包。救赎者机器人(RedeemerBot)建议,减少软件占用可以降低潜在的攻击面。
让我们来练习移除之前安装的 neofetch 软件包。在基于 Debian 的系统中,有两种主要的移除软件包的方法:
简单移除
若要在移除软件包的同时保留其配置文件(以便日后重新安装),请使用以下命令:
sudo apt remove neofetch
你会看到请求确认的输出信息:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
neofetch
0 upgraded, 0 newly installed, 1 to remove and X not upgraded.
After this operation, Y kB disk space will be freed.
Do you want to continue? [Y/n]
按 Enter
键,或者输入 y
后再按 Enter
键来确认。
彻底移除
若要彻底移除软件包及其配置文件,请使用以下命令:
sudo apt purge neofetch
如果你已经使用过 remove
命令,也可以使用以下命令清除剩余的配置文件:
sudo apt purge neofetch
输出信息与 remove
命令类似,但它还会删除配置文件。
清理不必要的软件包
移除软件包后,清理那些作为依赖项自动安装但不再需要的软件包是个好习惯:
sudo apt autoremove
这个命令会移除那些作为其他软件包的依赖项安装,但现在不再需要的软件包。
验证移除结果
要验证 neofetch 是否已被移除,尝试运行它:
neofetch
你应该会看到类似以下的错误信息:
Command 'neofetch' not found, but can be installed with:
sudo apt install neofetch
这证实了该软件包已成功从你的系统中移除。