使用 rpm 或 yum 擦除多个包 [英] Erase multiple packages using rpm or yum
问题描述
我可以访问安装了 50 多个 php rpm 的服务器.我正在尝试将它们全部删除.
I was given access to a server with 50+ php rpms installed. I'm trying to remove them all.
基本上,我正在尝试结合这两个命令:
Basically, I'm trying to combine these two commands:
rpm -qa | grep 'php'
和
rpm --erase
我对管道和重定向有一些了解,但我不知道如何将它们用于此目的.请帮忙.
I know a little about pipes and redirection, but I don't see how to use them for this purpose. Please help.
推荐答案
Using yum
列出并删除指定的包及其所有依赖项,但带有 y/N
确认:
yum remove 'php*'
要绕过确认,请将 yum
替换为 yum -y
.
To bypass the confirmation, replace yum
with yum -y
.
列出安装了哪些 RPM:
List which RPMs are installed:
rpm -qa 'php*'
rpm -qa | grep '^php' # Alternative listing.
列出哪些 RPM 将被删除,而不实际删除它们:
List which RPMs which will be erased, without actually erasing them:
rpm -e --test -vv $(rpm -qa 'php*') 2>&1 | grep '^D: erase:'
在 Amazon Linux 上,您可能需要改用 grep '^D: ========== ---'
.
On Amazon Linux, you may need to use grep '^D: ========== ---'
instead.
如果上述命令未列出相关 RPM,请调查错误:
If the relevant RPMs are not listed by the command above, investigate errors:
rpm -e --test -vv $(rpm -qa 'php*')
清除这些 RPM:
rpm -e $(rpm -qa 'php*')
确认擦除:
rpm -qa 'php*'
这篇关于使用 rpm 或 yum 擦除多个包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!