yum or rpm
When I install a software even if the rpm file is locally located I prefer using yum localinstall as it resolves dependencies if needed. But to uninstall a software should we use yum or rpm? Which is recommended?
Responses
Hi Srikanth,
To answer your initial question, if possible, use yum, that's the short answer. There are cases where you can use rpm....
NOTE: Also see the good tips from Jaromir Hradilek and Tom Jones below....
If you have not already, activate your Red Hat subscription, and you can activate it at this link https://access.redhat.com/subscriptions/activate/protected/activate.html?_flowId=activate-flow&_flowExecutionKey=e1s1.
The activation of your subscription should enable your yum repository from Red Hat (if you have not already done so). run a "yum clean all" and "yum repolist" after activating your subscription.
First of all, both rpm and yum have their place. rpm does not resolve software dependencies, yum does if it points to a proper yum repository for your system. Using the rpm command can land you into a not-wonderful place called "rpm dependency hell". For some info on "rpm dependency hell", see slide 8 of this Red Hat bit on package management TAKES A MOMENT TO LOAD, and the remaining slides at your convenience.
Using yum for install and removal helps with the dependency issues. When you go to uninstall software, yum will resolve dependencies as well. If possible, use yum to add and remove software to avoid 'dependency hell' (see slide 8 of the link in the last paragraph). There are exceptions of course, if you have a single or a couple of rpms with zero dependencies,
Some background for rpm
- Here is a good reference for rpm called "maximum rpm" website
Testing an rpm for install/removal without actually installing or removing it
- Test the install with "--test" (link further in this post):
rpm -ivh --test name_of_the_rpm
- Test the removal with "--test" (link further in this post):
-- NOTE: use the "--test" to test, omitting it will erase the rpm.
rpm -e --test name_of_the_rpm
[no output means it would run clean]
- or
rpm -evv --test name_of_the_rpm
[longer verbose output]
After determining the rpm has no dependencies, here is how to install it with the rpm command:
- you can use
rpm -ivh /path/to/the.rpm
Or if you had two rpms to install together:
rpm -ivh /path/to/the.rpm /another/path/to/another.rpm
Here is one way to test the removal of an rpm using yum, without actually executing the actual removal as follows:
-- and hit "n" when prompted (you can use the below to test an install, but switch "remove" with "install").
yum remove nameofthe_rpm
[output not listed here]
Is this ok [y/N]: n
Exiting on user Command
Alternatively, (I've never seen this documented), but this also does the same as above, but exits immediately:
echo n | yum remove nameofthe_rpm
Additional background
Yum and 3rd party software
- I've had to occasionally load software provided by third party vendors on my Red Hat systems that is in rpm format. I will often still use the following, because some software packages will still ask for additional libraries etc, and yum will attempt to resolve dependencies.
yum install /path/to/the_3rd_party_vendor.rpm
-
This may seem obvious, but I've seen it happen to another company - If you are dealing with unique channels or are creating your own yum repositories, only apply a workstation yum repository to a workstation, and server yum repository to RHEL server. Mixing those ends with bad consequences, and I know of a company that mixed these up and suffered some bad consequences. Get the versions right as well.
-
Some very brief background on the yum command
- Here is a video on basic yum use by Red Hat.
Hope this helps.
Thank you very much for putting this together, Remmele. For the sake of completeness, I would just like to add that both yum and rpm are documented in the System Administrator's Guide for Red Hat Enterprise Linux 7:
-
The Yum chapter documents how to use the yum command to search, list, install, uninstall, and update RPM packages. It also explains how to use the yum history subcommand to work with transaction history, how to configure, add, and create repositories, and how to enable and disable various Yum plug-ins.
-
The RPM appendix explains what RPM is and documents how to use the rpm command to examine, install, uninstall, and update RPM packages. This chapter also advises readers to use Yum instead of RPM whenever possible to perform package-management tasks.
For Red Hat Enterprise Linux 6, similar chapters exist in the Deployment Guide:
The yum history - particularly in a multi-administrator environment where direct root logins are prohibited - is one of the best reasons for using yum over RPM (at least for actually adding/removing software). Gives you a nice audit-trail of who did what and when - inclusive of actions that were "side effects" of a requested action-set. If you're not using an automated software management system, it's a nice accountability fallback.
While yum is a front-end to dealing with RPMs, the two are technically interchangable in use. That said, inconsistency in how you use them can lead to aesthetic annoyances (e.g., if you directly-use RPM to install something, the next time you run yum, you'll get a nag about the database having been altered outside of yum: the fix is easy, it's just an annoying thing to deal with).
Generally, my breakdown on things is to use yum as much as possible (i.e., for installations and removals and most interactive tasks) and use the legacy RPM utilitis primarily for reporting - particularly scripted-reporting - or manipulation of RPMs without installation (rpm2cpio being a good tool for doing partial de-archvies).
Here's an article regarding the "RPMDB altered outside of yum" annoyance at this link
Quoted from the above article:
"To remove the warning without installing or removing anything you can run following the command:"
# yum history new