RPM Command: 15 Examples To Install, Uninstall, Upgrade, Query RPM Packages
RPM Command: 15 Examples To Install, Uninstall, Upgrade, Query RPM Packages
RPM Command: 15 Examples To Install, Uninstall, Upgrade, Query RPM Packages
Tweet
With root privilege, you can use the rpm command with appropriate options to manage the RPM
software packages.
Let us take an rpm of Mysql Client and run through all our examples.
-i : install a package
-v : verbose
-h : print hash marks as the package archive is unpacked.
You can also use dpkg on Debian, pkgadd on Solaris, depot on HP-UX to install packages.
You can use rpm command to query all the packages installed in your system.
# rpm -qa
cdrecord-2.01-10.7.el5
bluez-libs-3.7-1.1
setarch-2.0-1.1
.
.
-q query operation
-a queries all installed packages
To identify whether a particular rpm package is installed on your system, combine rpm and grep
command as shown below. Following command checks whether cdrecord package is installed on
your system.
The above example lists all currently installed package. After installation of a package to check
the installation, you can query a particular package and verify as shown below.
# rpm -q MySQL-client
MySQL-client-3.23.57-1
# rpm -q MySQL
package MySQL is not installed
Note: To query a package, you should specify the exact package name. If the package name is
incorrect, then rpm command will report that the package is not installed.
Rpm command provides an option –queryformat, which allows you to give the header tag names,
to list the packages. Enclose the header tag with in {}.
5. Which RPM package does a file belong to? – Use rpm -qf
Let us say, you have list of files and you would want to know which package owns all these files.
rpm command has options to achieve this.
The following example shows that /usr/bin/mysqlaccess file is part of the MySQL-client-
3.23.57-1 rpm.
-f : file name
Use the following to know the list of documentations, for a package that owns a file. The
following command, gives the location of all the manual pages related to mysql package.
-d : refers documentation.
rpm command provides a lot of information about an installed pacakge using rpm -qi as shown
below:
# rpm -qi MySQL-client
Name : MySQL-client Relocations: (not relocatable)
Version : 3.23.57 Vendor: MySQL AB
Release : 1 Build Date: Mon 09 Jun 2003
11:08:28 PM CEST
Install Date: Mon 06 Feb 2010 03:19:16 AM PST Build Host:
build.mysql.com
Group : Applications/Databases Source RPM: MySQL-3.23.57-
1.src.rpm
Size : 5305109 License: GPL / LGPL
Signature : (none)
Packager : Lenz Grimmer
URL : http://www.mysql.com/
Summary : MySQL - Client
Description : This package contains the standard MySQL clients.
If you have an RPM file that you would like to install, but want to know more information about
it before installing, you can do the following:
To list the content of a RPM package, use the following command, which will list out the files
without extracting into the local directory folder.
10. Find out the state of files in a package using rpm -qsp
The following command is to find state (installed, replaced or normal) for all the files in a RPM
package.
Verifying a package compares information about the installed files in the package with
information about the files taken from the package metadata stored in the rpm database. In the
following command, -V is for verification and -p option is used to specify a package name to
verify.
The following command verify the package which owns the given filename.
Upgrading a package is similar to installing one, but RPM automatically un-installs existing
versions of the package before installing the new one. If an old version of the package is not
found, the upgrade option will still install it.
To remove an installed rpm package using -e as shown below. After uninstallation, you can
query using rpm -qa and verify the uninstallation.
# rpm -Va
S.5....T c /etc/issue
S.5....T c /etc/issue.net
S.5....T c /var/service/imap/ssl/seed
S.5....T c /home/httpd/html/horde/ingo/config/backends.php
.
.
S.5....T c /home/httpd/html/horde/ingo/config/prefs.php
S.5....T c /etc/printcap