Using Linux RPM Command

Scenario / Question:

How do I install software packages using rpm.

How do I list what software packages are installed.

How do I list information about a package.

How do I list files associated with a package.

How do I remove software packages I do not need.

How do I verify an installed package against RPM database to ensure its not different from original.

Solution / Answer:

Using the rpm command.

Install rpm packages

To install an rpm package issue the following command followed by the file name:

i – Install package

v – Verbose mode

h – Print 50 hash marks as the package archive is unpacked

# rpm -ivh sendmail-8.13.8-2.el5

Update rpm package

To update an rpm package use the “-U” attribute (not that the U is capital):

# rpm -Uvh sendmail-8.13.8-2.el5

List all installed software packages

Before we can begin removing software packages we need to know how to list the installed software packages on our system, and review description of the installed software packages to know what they are.

To list all the installed software packages on your system using the following command:

# rpm -qa

To see if a specific package is installed based on its name type the following command followed by the text of the package name:

# rpm -qa sendmail
sendmail-8.13.8-2.el5

List information about packages

To get a summary description about a certain package type the following command followed by the package name:

# rpm -qi sendmail
Name        : sendmail                     Relocations: (not relocatable)
Version     : 8.13.8                            Vendor: CentOS
Release     : 2.el5                         Build Date: Wed 14 Mar 2007 05:00:29 PM PDT
Install Date: Mon 01 Dec 2008 07:59:07 PM PST      Build Host: builder5.centos.org
Group       : System Environment/Daemons    Source RPM: sendmail-8.13.8-2.el5.src.rpm
Size        : 1370586                          License: Sendmail
Signature   : DSA/SHA1, Tue 03 Apr 2007 05:27:39 PM PDT, Key ID a8a447dce8562897
Summary     : A widely used Mail Transport Agent (MTA).
Description :
The Sendmail program is a very widely used Mail Transport Agent (MTA).
MTAs send mail from one machine to another. Sendmail is not a client
program, which you use to read your email. Sendmail is a
behind-the-scenes program which actually moves your email over
networks or the Internet to where you want it to go.

If you ever need to reconfigure Sendmail, you will also need to have
the sendmail.cf package installed. If you need documentation on
Sendmail, you can install the sendmail-doc package.

List files associated with a package

To list all files on the system that are associated with a package type the following command:

# rpm -ql sendmail
/etc/mail
/etc/mail/Makefile
/etc/mail/access
/etc/mail/domaintable
/etc/mail/helpfile
/etc/mail/local-host-names
/etc/mail/mailertable
/etc/mail/sendmail.cf
/etc/mail/sendmail.mc
...... continue

To list what package is associated with a specific file:

# rpm -qf /usr/sbin/sendmail
sendmail-8.13.8-2.el5

Remove software packages

Before we can attempt to remove a package we need to check if the package has any conflicts or dependencies. We use the rpm attribute “-e” for removing but include the attribute “–test” to only test and not actually attempt to remove the package:

# rpm -e --test sendmail
error: Failed dependencies:
        /usr/sbin/sendmail is needed by (installed) redhat-lsb-3.1-12.3.EL.el5.centos.i386
        smtpdaemon is needed by (installed) mdadm-2.6.4-1.el5.i386
        smtpdaemon is needed by (installed) mutt-1.4.2.2-3.0.2.el5.i386
        smtpdaemon is needed by (installed) fetchmail-6.3.6-1.1.el5.i386

Sendmail can not be directly uninstalled, because the package redhat-lsb-3.1-12.3.EL needs the file /usr/sbin/sendmail that is part of the sendmail software to be installed.

In order to uninstall sendmail we would need to remove the software programs that depended on sendmail as well. Otherwise those software packages will not work and you have a malfunctioning server system.

Remove a package without dependencies by using the attribute “-e”:

# rpm -e telnet

To force the removal of a package use the attribute “–nodeps–”:

# rpm -e --nodeps sendmail

Verify installed packages

Verifying an installed package is important for ensuring the files associated with a package have not been altered. This is useful for when a program is failing and as security measure.

Verify all files (This may take a long time):

# rpm --verify -a

Verify a packages files:

# rpm --verify sendmail
.......T c /etc/mail/sendmail.cf
S.5....T c /var/log/mail/statistics

If the result is empty then the package files are unaltered compared to the original state. With our test we received an output, therefore file sendmail.cf and statistics have altered.

Verify a specific file that is part of a package:

# rpm --verify --file /usr/sbin/sendmail
.......T c /etc/mail/sendmail.cf
S.5....T c /var/log/mail/statistics

Interpreting the verify results:

There are 8 tests performed and each tests result is shown before the file path. A dot “.” signifies a pass.

. . . . . . . . c /etc/mail/sendmail.cf

The tests and error codes are:

  • M – Mode
  • G – Group
  • U – User
  • D – Device
  • T – Time
  • L – Link
  • S – Size
  • 5 – MD5 checksum

Lets analyze our output, and keep in mind that not all altered files are bad:

S.5....T c /var/log/mail/statistics

“S” indicates that the size of the file has changed. This is expected since the file is a log file and will grow and be altered as the system operates.

“5″ indicates that the MD5 checksum has been altered from the original state. This is expected since the file is a log file and has changed.

“T” Indicates that the time associated with the file has changed. This is expected as the file is constantly being updated.

Getting a negative result from “–verify” is not also a reason for concern. However, if a main executable file such as “/usr/sbin/sendmail” was detected with errors then you would defiantly be concerned and investigate the issue.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
Fabio Milano has written 79 articles for us. Fabio Milano is a certified RHCE, MCP, and CFOI. He runs an IT consulting and services company called RDS Support inc. Website:http://www.rdssupport.com
The information provided is for educational purposes only. All content including links and comments is provided "as is" with no warranty, expressed or implied. Use is at your own risk and you are solely responsible for what you do with it.

5 Comments so far

  1. Rajesh kumar bijarniya on June 28th, 2011

    helpful and easy to understand…thanks…

  2. [...] Kaynak : http://www.kernelhardware.org/linux-rpm-command/ [...]

  3. param on November 16th, 2011

    very very good explanation
    thanks to like this support

  4. linuxnewbie on December 5th, 2011

    excellent article!

  5. Sac on January 1st, 2012

    i have installed adobe-flash thru apm. verified that its installed but how do i know where it is intalled and how can i use it???

Leave a reply