RPM Queries

From CDOT Wiki
Revision as of 18:19, 4 September 2012 by Chris Tyler (talk | contribs)
Jump to: navigation, search

Advantages of Using the RPM Package Manager

Software on a Linux system may be built from source and installed (download, extract, ./configure, make, make install). However, when software is installed this way, there is no simple way to manage it -- you cannot easily determine which packages are installed, the version of each package, which files belong to which package, and so forth. Updating and removing software is particularly problematic.

RPM provides a solution for these issues. It maintains a queryable database of installed software.

Note.png
Other Package Managers
RPM is not the only package manager used on Linux -- the Debian .deb system, used with the apt tool, provides similar functionality, and this system is also used on Ubuntu. For the purposes of this course, we will be focusing on the RPM system, which is used by most commercial Linux distributions, including Red Hat Enterprise Linux, SuSE, and others including Mandravia and CentOS.

Querying the RPM Database

RPM's -q option performs queries on the package database. It is a powerful option, and can be used for many different types of queries.

Query Options

RPM query options break down into two broad categories:

  • select-options, which determine which packages should be included in the query output
  • query-options, which determine what information should be displayed about the selected packages

Keeping these two option groups distinct in your mind is the key to taking full advantage of RPM queries.

Select-Options

Option Meaning Example
-a all installed packages rpm -q -a
-f filename package that owns filename rpm -q -f /etc/hosts
-p packagefile queries the uninstalled packagefile instead of the database rpm -q nautilus- - .src.rpm
--triggeredby package selects packages with trigger scripts that are activated by the package rpm -q --triggeredby firefox
--whatprovides capability selects packages which provide capability rpm -q --whatprovides smtpdaemon
--whatrequires capability selects packages which require capabililty rpm -q --whatrequires bash

Query-Options

Option Meaning Example
--changelog shows the changelog entries rpm -q --changelog bash
-c shows the absolute pathnames of config files rpm -q -c sendmail
-d shows the absolute pathnames of documentation files rpm -q -d httpd
-l shows the absolute pathnames of files rpm -q -f firefox
--filesbypackage same as -l but preceded by the package name rpm -q --filesbypackage -q
-i verbose information (metadata) about the package, including license, build host, summary, description, build date, install date, and so forth rpm -q -i gedit
--last shows the package name and last transaction date rpm -q --last python
--requires shows capabilities required (dependencies) rpm -q --requires nled
--provides shows capabilities provided (which may be required by other packages) rpm -q --provides zsh
--scripts shows scriptlets (preinstall, postinstall, preuninstall, postuninstall) rpm -q --scripts evolution
--triggers shows trigger scriptlets rpm -q --triggers flash-plugin