RedHat – Useful YUM and RPM commands

Install the package

YUM installs the package if it is not already present and updates it with the latest version available from repo if the package already installed and present.

#yum install <package>

Check which package (available from repo) provides the binary file/command.

#yum provides <binary file/command>

yum_provides

Often we want to see what are the list of versions available for same package so that we install a specific version. From https://unix.stackexchange.com/questions/151689/how-can-i-instruct-yum-to-install-a-specific-version-of-package-x

$ yum --showduplicates list httpd | expand
Loaded plugins: fastestmirror, langpacks, refresh-packagekit
Loading mirror speeds from cached hostfile
 * fedora: mirror.steadfast.net
 * rpmfusion-free: csc.mcs.sdsmt.edu
 * rpmfusion-free-updates: csc.mcs.sdsmt.edu
 * rpmfusion-nonfree: csc.mcs.sdsmt.edu
 * rpmfusion-nonfree-updates: csc.mcs.sdsmt.edu
 * updates: mirror.steadfast.net
Available Packages
httpd.x86_64                        2.4.6-6.fc20                         fedora 
httpd.x86_64                        2.4.10-1.fc20                        updates

As far as installing a particular version? You can append the version info to the name of the package like so:

$ sudo yum install <package name>-<version info>

For example in this case if I wanted to install the older version, 2.4.6-6 I’d do the following:

$ sudo yum install httpd-2.4.6-6

You can also include the release info when specifying a package. In this case since I’m dealing with Fedora 20 (F20) the release info would be “fc20”, and the architecture info too.

$ sudo yum install httpd-2.4.6-6.fc20
$ sudo yum install httpd-2.4.6-6.fc20.x86_64

Individual commands for RPM to install and update.

#rpm -ivh <package>
#rpm -Uvh <package>

Note: Always install the new kernel instead of updating.

Download Only

You can also use one of the following options to download a particular RPM from the web, and then use yum to install it.

$ yum --downloadonly <package>
-or-
$ yumdownloader <package>

And then install it like so:

$ sudo yum localinstall <path to rpm>

What if I want to download everything that package X requires?

$ yumdownloader --resolve <package>

Example

$ yumdownloader --resolve vim-X11
Loaded plugins: langpacks, presto, refresh-packagekit
Adding en_US to language list
--> Running transaction check
---> Package vim-X11.x86_64 2:7.3.315-1.fc14 set to be reinstalled
--> Finished Dependency Resolution
vim-X11-7.3.315-1.fc14.x86_64.rpm    

Remove the package

#yum remove <package>
#rpm -e <package>

Packages update history

History of packages install/update/erase

#yum history list
#yum history list all

yum_history_list.JPG

If we want to see what are the packages changed in that transaction

#yum history info <id>

yum_history_info.JPG

History of single package since the installation

#yum history package <package>

yum_history_package.JPG

On old RHEL there is no history option for yum command.  If we want to see the package versions changed with the date and time run the rpm

#rpm -qa --last

rpm_last

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s