With the -q
option, rpm initiates
queries, making it possible to inspect an RPM archive (by adding the option
-p
) and also to query the RPM database of installed
packages. Several switches are available to specify the type of information
required. See Table 16.1, “The Most Important RPM Query Options”.
Table 16.1. The Most Important RPM Query Options
| Package information |
| File list |
| Query the package that contains the file
|
| File list with status information (implies
|
| List only documentation files (implies |
| List only configuration files (implies
|
| File list with complete details (to be used with
|
| List features of the package that another package can request with
|
| Capabilities the package requires |
| Installation scripts (preinstall, postinstall, uninstall) |
For example, the command rpm -q -i wget displays the information shown in Example 16.1, “rpm -q -i wget”.
Example 16.1. rpm -q -i wget
Name : wget Relocations: (not relocatable) Version : 1.9.1 Vendor: SUSE LINUX AG, Nuernberg, Germany Release : 50 Build Date: Sat 02 Oct 2004 03:49:13 AM CEST Install date: Mon 11 Oct 2004 10:24:56 AM CEST Build Host: f53.suse.de Group : Productivity/Networking/Web/Utilities Source RPM: wget-1.9.1-50.src.rpm Size : 1637514 License: GPL Signature : DSA/SHA1, Sat 02 Oct 2004 03:59:56 AM CEST, Key ID a84edae89c800aca Packager : http://www.suse.de/feedback URL : http://wget.sunsite.dk/ Summary : A tool for mirroring FTP and HTTP servers Description : Wget enables you to retrieve WWW documents or FTP files from a server. This can be done in script files or via the command line. [...]
The option -f
only works if you specify the
complete filename with its full path. Provide as many filenames as
desired. For example, the following command
rpm -q -f /bin/rpm /usr/bin/wget
results in:
rpm-4.1.1-191 wget-1.9.1-50
If only part of the filename is known, use a shell script as shown in Example 16.2, “Script to Search for Packages”. Pass the partial filename to the script shown as a parameter when running it.
Example 16.2. Script to Search for Packages
#! /bin/sh for i in $(rpm -q -a -l | grep $1); do echo "\"$i\" is in package:" rpm -q -f $i echo "" done
The command rpm -q --changelog rpm displays a detailed
list of change information about a specific package, sorted by date. This
example shows information about the package rpm
.
With the help of the installed RPM database, verification checks can be
made. Initiate these with -V
,
-y
, or --verify
. With this option,
rpm shows all files in a package that have been
changed since installation. rpm uses eight character
symbols to give some hints about the following changes:
Table 16.2. RPM Verify Options
| MD5 check sum |
| File size |
| Symbolic link |
| Modification time |
| Major and minor device numbers |
| Owner |
| Group |
| Mode (permissions and file type) |
In the case of configuration files, the letter c
is
printed. For example, for changes to /etc/wgetrc
(wget
):
rpm -V wget S.5....T c /etc/wgetrc
The files of the RPM database are placed in
/var/lib/rpm
. If the partition /usr
has a size of 1 GB, this database
can occupy nearly 30 MB, especially after a complete update. If the
database is much larger than expected, it is useful to rebuild the database
with the option --rebuilddb
. Before doing this, make a
backup of the old database. The cron script
cron.daily makes daily copies of the database (packed
with gzip) and stores them in /var/adm/backup/rpmdb
.
The number of copies is controlled by the variable
MAX_RPMDB_BACKUPS
(default: 5
) in
/etc/sysconfig/backup
. The size of a single backup is
approximately 1 MB for 1 GB in
/usr
.