如何卸载CentOS9系统中无用的软件包?
美国、香港服务器
如何卸载CentOS9系统中无用的软件包?
05-11 来源:
一、自动卸载无用依赖(最安全首选)
自动删掉安装软件后残留的无用依赖、孤立包:
bash
运行
dnf autoremove -y
这条最安全,不会删系统必需组件,直接执行就行。
二、清理 DNF/Yum 缓存包
清理下载后残留的安装包缓存,释放空间:
bash
运行
dnf clean all
三、查看已安装所有软件包
bash
运行
dnf list installed
四、查找可以卸载的无用包
1. 查看可移除的分组软件
列出系统预装组件分组(如办公、游戏、语言包):
bash
运行
dnf group list
2. 删除无用软件分组(示例)
比如删掉预装的游戏、办公套件、多余语言包:
bash
运行
# 卸载游戏套件
dnf group remove "Games and Entertainment" -y
# 卸载多余办公套件
dnf group remove "Office Suite and Productivity" -y
五、卸载指定单个软件包
格式:
bash
运行
dnf remove 软件名 -y
示例:
bash
运行
# 卸载httpd Apache
dnf remove httpd -y
# 卸载mariadb
dnf remove mariadb-server -y
# 卸载vsftpd FTP
dnf remove vsftpd -y
六、删除旧内核(安全省空间)
查看当前正在用内核(千万别删这个)
bash
运行
uname -r
列出所有已安装内核
bash
运行
rpm -qa | grep kernel
卸载旧内核(保留当前 + 1 个最新即可)
bash
运行
dnf remove 旧内核版本包名 -y
七、谨慎不要卸载的包(避坑)
下面这些千万别删,删了系统崩、SSH 连不上:
systemd
firewalld
sshd
network-manager
dnf、rpm 本身
glibc 系统基础库
八、一键全套清理命令(直接复制执行)
bash
运行
dnf autoremove -y
dnf clean all
三二互联专业提供香港VPS,美国VPS主机,香港云服务器租用等业务香港美国到大陆CN2 GIA速度最快