yum vs rpm

The major differences between YUM and RPM are that yum knows how to resolve dependencies and can source these additional packages when doing its work. Though rpm can alert you to these dependencies, it is unable to source additional packages.

To install an RPM package, we use of the -i flag. 

# rpm -ivh kernel-2.4.21-15.0.3.EL.i686.rpm
Preparing...                ########################################### [100%]
   1:kernel                 ########################################### [100%]
To upgrade an RPM package, we use of the -U flag


# rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm mod_ssl-2.0.46-32.ent.3.i386.rpm
Preparing...                ########################################### [100%]
   1:httpd                  ########################################### [ 50%]
   2:mod_ssl                ########################################### [100%]
# rpm -q httpd; rpm -q mod_ssl
httpd-2.0.46-32.ent.3
mod_ssl-2.0.46-32.ent.3
Note: The httpd and mod_ssl needed to be installed at the same time because of dependency issues. If you try to install one without the other, you would get an error similar to the following:
# rpm -Uvh httpd-2.0.46-32.ent.3.i386.rpm
error: Failed dependencies:
        httpd = 2.0.46-32.ent is needed by (installed) mod_ssl-2.0.46-32.ent

How to Install an RPM Package

[root@tecmint]# rpm -ivh pidgin-2.7.9-5.el6.2.i686.rpm
Preparing...                ########################################### [100%]
1:pidgin                 ########################################### [100%]
RPM command and options

  1. -i : install a package
  2. -v : verbose for a nicer display
  3. -h: print hash marks as the package archive is unpacked.


How to check dependencies of RPM Package before Installing

Let’s say you would like to do a dependency check before installing or upgrading a package. For example, use the following command to check the dependencies of BitTorrent-5.2.2-1-Python2.4.noarch.rpm package. It will display the list of dependencies of package.
[root@tecmint]# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm
/usr/bin/python2.4
python >= 2.3
python(abi) = 2.4
python-crypto >= 2.0
python-psyco
python-twisted >= 2.0
python-zopeinterface
rpmlib(CompressedFileNames) = 2.6
RPM command and options

  1. -q : Query a package
  2. -p : List capabilities this package provides.
  3. -R: List capabilities on which this package depends..

How to Install a RPM Package Without Dependencies

If you know that all needed packages are already installed and RPM is just being stupid, you can ignore those dependencies by using the option –nodeps (no dependencies check) before installing the package.

[root@tecmint]# rpm -ivh --nodeps BitTorrent-5.2.2-1-Python2.4.noarch.rpm
Preparing...                ########################################### [100%]
1:BitTorrent             ########################################### [100%]

How to check an Installed RPM Package

Using -q option with package name, will show whether an rpm installed or not.

[root@tecmint]# rpm -q BitTorrent
BitTorrent-5.2.2-1.noarch

How to List all files of an installed RPM package

To view all the files of an installed rpm packages, use the -ql (query list) with rpm command.

[root@tecmint]# rpm -ql BitTorrent
/usr/bin/bittorrent
/usr/bin/bittorrent-console
/usr/bin/bittorrent-curses
/usr/bin/bittorrent-tracker

How to List Recently Installed RPM Packages

Use the following rpm command with -qa (query all) option, will list all the recently installed rpm packages.

[root@tecmint]# rpm -qa --last
BitTorrent-5.2.2-1.noarch                     Tue 04 Dec 2012 05:14:06 PM BDT
pidgin-2.7.9-5.el6.2.i686                     Tue 04 Dec 2012 05:13:51 PM BDT
cyrus-sasl-devel-2.1.23-13.el6_3.1.i686       Tue 04 Dec 2012 04:43:06 PM BDT
cyrus-sasl-2.1.23-13.el6_3.1.i686             Tue 04 Dec 2012 04:43:05 PM BDT

How to List All Installed RPM Packages

Type the following command to print the all the names of installed packages on your Linux system.

[root@tecmint]# rpm -qa
initscripts-9.03.31-2.el6.centos.i686
polkit-desktop-policy-0.96-2.el6_0.1.noarch
thunderbird-17.0-1.el6.remi.i686

How to Upgrade a RPM Package

If we want to upgrade any RPM package “–U” (upgrade) option will be used. One of the major advantages of using this option is that it will not only upgrade the latest version of any package, but it will also maintain the backup of the older package so that in case if the newer upgraded package does not run the previously installed package can be used again.

[root@tecmint]# rpm -Uvh nx-3.5.0-2.el6.centos.i686.rpm
Preparing...                ########################################### [100%]
1:nx                     ########################################### [100%]


How to Remove a RPM Package

To un-install an RPM package, for example we use the package name nx, not the original package name nx-3.5.0-2.el6.centos.i686.rpm. The -e (erase) option is used to remove package.

[root@tecmint]# rpm -evv nx

How to Remove an RPM Package Without Dependencies

The –nodeps (Do not check dependencies) option forcefully remove the rpm package from the system. But keep in mind removing particular package may break other working applications.

[root@tecmint]# rpm -ev --nodeps vsftpd

How to Query a file that belongs which RPM Package

Let’s say, you have list of files and you would like to find out which package belongs to these files. For example, the following command with -qf (query file) option will show you a file /usr/bin/htpasswd is own by package httpd-tools-2.2.15-15.el6.centos.1.i686.

[root@tecmint]# rpm -qf /usr/bin/htpasswd
httpd-tools-2.2.15-15.el6.centos.1.i686

How to Query a Information of Installed RPM Package

Let’s say you have installed an rpm package and want to know the information about the package. The following -qi (query info) option will print the available information of the installed package.

[root@tecmint]# rpm -qi vsftpd
Name        : vsftpd       Relocations: (not relocatable)
Version     : 2.2.2       Vendor: CentOS
Release     : 11.el6       Build Date: Fri 22 Jun 2012 01:54:24 PM BDT
Install Date: Mon 17 Sep 2012 07:55:28 PM BDT      Build Host: c6b8.bsys.dev.centos.org
Group       : System Environment/Daemons           Source RPM: vsftpd-2.2.2-11.el6.src.rpm
Size        : 351932                               License: GPLv2 with exceptions
Signature   : RSA/SHA1, Mon 25 Jun 2012 04:07:34 AM BDT, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://vsftpd.beasts.org/
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.

Get the Information of RPM Package Before Installing

You have download a package from the internet and want to know the information of a package before installing. For example, the following option -qip (query info package) will print the information of a package sqlbuddy.

[root@tecmint]# rpm -qip sqlbuddy-1.3.3-1.noarch.rpm
Name        : sqlbuddy                     Relocations: (not relocatable)
Version     : 1.3.3                        Vendor: (none)
Release     : 1                            Build Date: Wed 02 Nov 2011 11:01:21 PM BDT
Install Date: (not installed)              Build Host: rpm.bar.baz
Group       : Applications/Internet        Source RPM: sqlbuddy-1.3.3-1.src.rpm
Size        : 1155804                      License: MIT
Signature   : (none)
Packager    : Erik M Jacobs
URL         : http://www.sqlbuddy.com/
Summary     : SQL Buddy â Web based MySQL administration
Description :
SQLBuddy is a PHP script that allows for web-based MySQL administration.

How to Query documentation of Installed RPM Package

To get the list of available documentation of an installed package, use the following command with option -qdf (query document file) will display the manual pages related to vmstat package.

[root@tecmint]# rpm -qdf /usr/bin/vmstat
/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
/usr/share/doc/procps-3.2.8/TODO



How to Verify a RPM Package

Verifying a package compares information of installed files of the package against the rpm database. The -Vp (verify package) is used to verify a package.

[root@tecmint downloads]# rpm -Vp sqlbuddy-1.3.3-1.noarch.rpm
S.5....T.  c /etc/httpd/conf.d/sqlbuddy.conf

How to Verify all RPM Packages

Type the following command to verify all the installed rpm packages.

[root@tecmint]# rpm -Va
S.5....T.  c /etc/rc.d/rc.local
.......T.  c /etc/dnsmasq.conf
.......T.    /etc/ld.so.conf.d/kernel-2.6.32-279.5.2.el6.i686.conf
S.5....T.  c /etc/yum.conf
S.5....T.  c /etc/yum.repos.d/epel.repo


How to Import an RPM GPG key

To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key.

[root@tecmint]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


How to List all Imported RPM GPG keys

To print all the imported GPG keys in your system, use the following command.

[root@tecmint]# rpm -qa gpg-pubkey*
gpg-pubkey-0608b895-4bd22942


How To rebuild Corrupted RPM Database

Sometimes rpm database gets corrupted and stops all the functionality of rpm and other applications on the system. So, at the time we need to rebuild the rpm database and restore it with the help of following command.

[root@tecmint]# cd /var/lib
[root@tecmint]# rm __db*
[root@tecmint]# rpm --rebuilddb
[root@tecmint]# rpmdb_verify Packages
===============================
YUM


Install a Package with YUM

To install a package called Firefox 14, just run the below command it will automatically find and install all required dependencies for Firefox.
# yum install firefox


To remove a package completely with their all dependencies, just run the following command as shown below.

# yum remove firefox

Updating a Package using YUM

Let’s say you have outdated version of MySQL package and you want to update it to the latest stable version. Just run the following command it will automatically resolves all dependencies issues and install them.

# yum update mysql

List a Package using YUM

Use the list function to search for the specific package with name. For example to search for a package called openssh, use the command.

# yum list openssh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* epel: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* rpmforge: mirror.nl.leaseweb.net
* updates: mirror.nus.edu.sg
Installed Packages
openssh.i386                                       4.3p2-72.el5_6.3                                                                      installed
Available Packages                                 4.3p2-82.el5     

Search for a Package using YUM

If you don’t remember the exact name of the package, then use search function to search all the available packages to match the name of the package you specified. For example, to search all the packages that matches the word .

# yum search vsftpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* epel: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* rpmforge: mirror.nl.leaseweb.net
* updates: ftp.iitm.ac.in
============================== Matched: vsftpd ========================
ccze.i386 : A robust log colorizer
pure-ftpd-selinux.i386 : SELinux support for Pure-FTPD
vsftpd.i386 : vsftpd - Very Secure Ftp Daemon

Get Information of a Package using YUM

Say you would like to know information of a package before installing it. To get information of a package just issue the below command.

# yum info firefox
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.neu.edu.cn
* epel: mirror.neu.edu.cn
* extras: mirror.neu.edu.cn
* rpmforge: mirror.nl.leaseweb.net
* updates: ftp.iitm.ac.in
Available Packages
Name       : firefox
Arch       : i386
Version    : 10.0.6
Release    : 1.el5.centos
Size       : 20 M
Repo       : updates
Summary    : Mozilla Firefox Web browser
URL        : http://www.mozilla.org/projects/firefox/
License    : MPLv1.1 or GPLv2+ or LGPLv2+
Description: Mozilla Firefox is an open-source web browser, designed for standards
: compliance, performance and portability.

List all Available Packages using YUM

To list all the available packages in the Yum database, use the below command.

# yum list | less

List all Installed Packages using YUM

To list all the installed packages on a system, just issue below command, it will display all the installed packages.

# yum list installed | less

Yum Provides Function

Yum provides function is used to find which package a specific file belongs to. For example, if you would like to know the name of the package that has the /etc/httpd/conf/httpd.conf.

# yum provides /etc/httpd/conf/httpd.conf
Loaded plugins: fastestmirror
httpd-2.2.3-63.el5.centos.i386 : Apache HTTP Server
Repo        : base
Matched from:
Filename    : /etc/httpd/conf/httpd.conf
httpd-2.2.3-63.el5.centos.1.i386 : Apache HTTP Server
Repo        : updates
Matched from:
Filename    : /etc/httpd/conf/httpd.conf
httpd-2.2.3-65.el5.centos.i386 : Apache HTTP Server
Repo        : updates
Matched from:
Filename    : /etc/httpd/conf/httpd.conf
httpd-2.2.3-53.el5.centos.1.i386 : Apache HTTP Server
Repo        : installed
Matched from:
Other       : Provides-match: /etc/httpd/conf/httpd.conf

Check for Available Updates using Yum

To find how many of installed packages on your system have updates available, to check use the following command.

# yum check-update

Update System using Yum

To keep your system up-to-date with all security and binary package updates, run the following command. It will install all latest patches and security updates to your system.

# yum update

List all available Group Packages

In Linux, number of packages are bundled to particular group. Instead of installing individual packages with yum, you can install particular group that will install all the related packages that belongs to the group. For example to list all the available groups, just issue following command.

# yum grouplist
Installed Groups:
Administration Tools
DNS Name Server
Dialup Networking Support
Editors

Install a Group Packages

To install a particular package group, we use option as groupinstall. Fore example, to install “MySQL Database“, just execute the below command.

# yum groupinstall 'MySQL Database'
Dependencies Resolved
=================================================================================================
Package        Arch      Version    Repository        Size
=================================================================================================
Updating:
unixODBC                           i386      2.2.11-10.el5      base              290 k
Installing for dependencies:
unixODBC-libs                      i386      2.2.11-10.el5      base              551 k
Transaction Summary

Update a Group Packages

To update any existing installed group packages, just run the following command as shown below.

# yum groupupdate 'DNS Name Server'

List Enabled Yum Repositories

To list all enabled Yum repositories in your system, use following option.

# yum repolist
repo id                     repo name                                            status
base                        CentOS-5 - Base                                      enabled:  2,725
epel                        Extra Packages for Enterprise Linux 5 - i386         enabled:  5,783
extras                      CentOS-5 - Extras                                    enabled:    282
mod-pagespeed               mod-pagespeed                                        enabled:      1
rpmforge                    RHEL 5 - RPMforge.net - dag                          enabled: 11,290
updates                     CentOS-5 - Updates                                   enabled:    743
repolist: 20,824

List all Enabled and Disabled Yum Repositories

The following command will display all enabled and disabled yum repositories on the system.

# yum repolist all
repo id                     repo name                                            status
C5.0-base                   CentOS-5.0 - Base                                    disabled
C5.0-centosplus             CentOS-5.0 - Plus                                    disabled
C5.0-extras                 CentOS-5.0 - Extras                                  disabled
base                        CentOS-5 - Base                                      enabled:  2,725
epel                        Extra Packages for Enterprise Linux 5 - i386         enabled:  5,783
extras                      CentOS-5 - Extras                                    enabled:    282
repolist: 20,824

Install a Package from Specific Repository

To install a particular package from a specific enabled or disabled repository, you must use –enablerepo option in your yum command. For example to Install PhpMyAdmin 3.5.2 package, just execute the command.

# yum --enablerepo=epel install phpmyadmin
Dependencies Resolved
=============================================================================================
Package                Arch           Version            Repository           Size
=============================================================================================
Installing:
phpMyAdmin             noarch         3.5.1-1.el6        epel                 4.2 M
Transaction Summary
=============================================================================================
Install       1 Package(s)
Total download size: 4.2 M
Installed size: 17 M
Is this ok [y/N]: y
Downloading Packages:
phpMyAdmin-3.5.1-1.el6.noarch.rpm                       | 4.2 MB     00:25
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : phpMyAdmin-3.5.1-1.el6.noarch             1/1
Verifying  : phpMyAdmin-3.5.1-1.el6.noarch             1/1
Installed:
phpMyAdmin.noarch 0:3.5.1-1.el6
Complete!

Clean Yum Cache

By default yum keeps all the repository enabled package data in /var/cache/yum/ with each sub-directory, to clean all cached files from enabled repository, you need to run the following command regularly to clean up all the cache and make sure that there is nothing unnecessary space is using. We don’t want to give the output of the below command, because we like to keep cached data as it is.

# yum clean all

View History of Yum

To view all the past transactions of yum command, just use the following command.

# yum history
Loaded plugins: fastestmirror
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
10 | root               | 2012-08-11 15:19 | Install        |    3
9 | root               | 2012-08-11 15:11 | Install        |    1
8 | root               | 2012-08-11 15:10 | Erase          |    1 EE
7 | root               | 2012-08-10 17:44 | Install        |    1
6 | root               | 2012-08-10 12:19 | Install        |    2
5 | root               | 2012-08-10 12:14 | Install        |    3
4 | root               | 2012-08-10 12:12 | I, U           |   13 E<
3 | root               | 2012-08-09 13:01 | Install        |    1 >
2 | root               | 2012-08-08 20:13 | I, U           |  292 EE
1 | System            | 2012-08-08 17:15 | Install        |  560
history list

List all available yum packages

To list all packages that are available to you using the yum command, use the yum list command:
yum list all
That should be a long list, so you'll probably want to pipe that into more or grep, like this:
yum list all | more
or this:
yum list all | grep -v installed | more

List installed yum packages

To list all installed packages use the yum list installed command:
yum list installed
or
yum list installed | more

See if an individual yum package is installed

To see if a particular package is installed the yum list command is still good. On my test server this command:

yum list mysql

Comments

Popular posts from this blog

HAproxy logging

tomcat catalina coyote jasper cluster

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all