Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

B.4. Practical and Common Examples of RPM Usage

RPM is a useful tool for both managing your system and diagnosing and fixing problems. The best way to make sense of all its options is to look at some examples.
  • Perhaps you have deleted some files by accident, but you are not sure what you deleted. To verify your entire system and see what might be missing, you could try the following command:
    rpm -Va
    If some files are missing or appear to have been corrupted, you should probably either re-install the package or uninstall and then re-install the package.
  • At some point, you might see a file that you do not recognize. To find out which package owns it, enter:
    rpm -qf /usr/bin/ghostscript
    The output would look like the following:
    ghostscript-8.70-1.el6.x86_64
  • We can combine the above two examples in the following scenario. Say you are having problems with /usr/bin/paste. You would like to verify the package that owns that program, but you do not know which package owns paste. Enter the following command,
    rpm -Vf /usr/bin/paste
    and the appropriate package is verified.
  • Do you want to find out more information about a particular program? You can try the following command to locate the documentation which came with the package that owns that program:
    rpm -qdf /usr/bin/free
    The output would be similar to the following:
    /usr/share/doc/procps-3.2.8/BUGS
    /usr/share/doc/procps-3.2.8/FAQ
    /usr/share/doc/procps-3.2.8/NEWS
    /usr/share/doc/procps-3.2.8/TODO
    /usr/share/man/man1/free.1.gz
    /usr/share/man/man1/pgrep.1.gz
    /usr/share/man/man1/pkill.1.gz
    /usr/share/man/man1/pmap.1.gz
    /usr/share/man/man1/ps.1.gz
    /usr/share/man/man1/pwdx.1.gz
    /usr/share/man/man1/skill.1.gz
    /usr/share/man/man1/slabtop.1.gz
    /usr/share/man/man1/snice.1.gz
    /usr/share/man/man1/tload.1.gz
    /usr/share/man/man1/top.1.gz
    /usr/share/man/man1/uptime.1.gz
    /usr/share/man/man1/w.1.gz
    /usr/share/man/man1/watch.1.gz
    /usr/share/man/man5/sysctl.conf.5.gz
    /usr/share/man/man8/sysctl.8.gz
    /usr/share/man/man8/vmstat.8.gz
  • You may find a new RPM, but you do not know what it does. To find information about it, use the following command:
    rpm -qip crontabs-1.10-32.1.el6.noarch.rpm
    The output would be similar to the following:
    Name        : crontabs                     Relocations: (not relocatable)
    Version     : 1.10                              Vendor: Red Hat, Inc.
    Release     : 32.1.el6                      Build Date: Thu 03 Dec 2009 02:17:44 AM CET
    Install Date: (not installed)               Build Host: js20-bc1-11.build.redhat.com
    Group       : System Environment/Base       Source RPM: crontabs-1.10-32.1.el6.src.rpm
    Size        : 2486                             License: Public Domain and GPLv2
    Signature   : RSA/8, Wed 24 Feb 2010 08:46:13 PM CET, Key ID 938a80caf21541eb
    Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
    Summary     : Root crontab files used to schedule the execution of programs
    Description :
    The crontabs package contains root crontab files and directories.
    You will need to install cron daemon to run the jobs from the crontabs.
    The cron daemon such as cronie or fcron checks the crontab files to
    see when particular commands are scheduled to be executed.  If commands
    are scheduled, it executes them.
    Crontabs handles a basic system function, so it should be installed on
    your system.
  • Perhaps you now want to see what files the crontabs RPM package installs. You would enter the following:
    rpm -qlp crontabs-1.10-32.1.el6.noarch.rpm
    The output is similar to the following:
    /etc/cron.daily
    /etc/cron.hourly
    /etc/cron.monthly
    /etc/cron.weekly
    /etc/crontab
    /usr/bin/run-parts
    /usr/share/man/man4/crontabs.4.gz
These are just a few examples. As you use RPM, you may find more uses for it.