-->

Previous | Table of Contents | Next

Page 75

5.2.5. --rcfile <rcfile>: Use <rcfile> As an Alternate rpmrc File

The --rcfile option is used to specify a file containing default settings for RPM. Normally, this option is not needed. By default, RPM uses /etc/rpmrc and a file named .rpmrc, located in your login directory.

This option would be used if there were a need to switch between several sets of RPM options. Software developers and package builders will be the people using --rcfile. For more information on rpmrc files, see Appendix B, "The rpmrc Files"

5.2.6. --dbpath <path>: Use <path> to Find an RPM Database

In order for RPM to do its work, it needs access to an RPM database. Normally, this database exists in the directory specified by the rpmrc file entry dbpath. By default, dbpath is set to /var/lib/rpm.

Although the dbpath entry can be modified in the appropriate rpmrc file, the --dbpath option is probably a better choice when the database path needs to be changed temporarily. An example of a time when the --dbpath option would come in handy is when it's necessary to examine an RPM database copied from another system. Granted, it's not a common occurrence, but it's difficult to handle any other way.

5.3. A Few Handy Queries

The following sections describe some examples of situations you might find yourself in, and ways you can use RPM to get the information you need. Keep in mind that these are just examples. Don't be afraid to experiment!

5.3.1. Finding Config Files Based on a Program Name

You're setting up a new system, and you'd like to implement some systemwide aliases for people using the Bourne again shell, bash. The problem is you just can't remember the name of the systemwide initialization file used by bash, or where it resides:


# rpm -qcf /bin/bash

/etc/bashrc

#

Rather than spend your time trying to hunt down the file, RPM finds it for you in seconds.

Page 76

5.3.2. Learning More About an Uninstalled Package

Practically any option can be combined with -qp to extract information from an .rpm file. Let's say you have an unknown .rpm file, and you'd like to know a bit more before installing it:


# rpm -qpil foo.bar

Name        : rpm               Distribution: Red Hat Linux Vanderbilt

Version     : 2.3                     Vendor: Red Hat Software

Release     : 1                   Build Date: Tue Dec 24 09:07:59 1996

Install date:    (none)           Build Host: porky.redhat.com

Group       : Utilities/System    Source RPM: rpm-2.3-1.src.rpm

Size        : 631157

Summary     : Red Hat Package Manager

Description :

RPM is a powerful package manager, which can be used to build, install,

query, verify, update, and uninstall individual software packages. A package

consists of an archive of files, and package information, including name,

version, and description.

/bin/rpm

/usr/bin/find-provides

/usr/bin/find-requires

/usr/bin/gendiff

/usr/bin/rpm2cpio

/usr/doc/rpm-2.3-1

...

 /usr/src/redhat/SOURCES

/usr/src/redhat/SPECS

/usr/src/redhat/SRPMS

#

By displaying the package information, we know that we have a package file containing RPM version 2.3. We can then peruse the file list and see exactly what it would install before installing it.

5.3.3. Finding Documentation for a Specific Package

Picking on bash some more, you realize that your knowledge of the software is lacking. You'd like to see when it was installed on your system and what documentation is available for it:


# rpm -qid bash

Name        :bash                       Distribution: Red Hat Linux (Picasso)

Version     :1.14.6                           Vendor: Red Hat Software

Release     :2                            Build Date: Sun Feb 25 13:59:26 1996

Install date:    Mon May 13 12:47:22 1996 Build Host: porky.redhat.com

Group       :Shells                          Source RPM: bash-1.14.6-2.src.rpm

Size        :486557

Description :GNU Bourne Again Shell (bash)

/usr/doc/bash-1.14.6-2

/usr/doc/bash-1.14.6-2/NEWS

/usr/doc/bash-1.14.6-2/README

/usr/doc/bash-1.14.6-2/RELEASE

/usr/info/bash.info.gz

/usr/man/man1/bash.1

#

You never realized that there could be so much documentation for a shell!

Page 77

5.3.4. Finding Similar Packages

Looking at bash's information, we see that it belongs to the group Shells. You're not sure what other shell packages are installed on your system. If you can find other packages in the Shells group, you'll have found the other installed shells:


# rpm -qa --queryformat `%10{NAME} %20{GROUP}\n' | grep -i shells

     ash    Shells

    bash    Shells

     csh    Shells

      mc    Shells

    tcsh    Shells

#

Now you can query each of these packages and learn more about them, too.


NOTE
Did you see this example and say to yourself, "Hey, they could've used the -g option to query for that group directly"? If you did, you've been paying attention. This is a more general way of searching the RPM database for information. We just happened to search by group in this example.

5.3.5. Finding Recently Installed Packages, Part I

Let's say you installed a new package a few days ago. All you know for certain is that the package installed a new command in the /bin directory. Let's try to find the package:


# find /bin -type f -mtime -14 | rpm -qF

rpm-2.3-1

#

Looks like RPM version 2.3 was installed sometime in the last two weeks.

5.3.6. Finding Recently Installed Packages, Part II

Another way to see which packages were recently installed is to use the --queryformat option:


# rpm -qa --queryformat\

> `%{installtime} %{name}-%{version}-%{release} %{installtime:date}\n'\

> | sort -nr +1 | sed -e `s/^[^ ]* //'

rpm-devel-2.3-1 Thu Dec 26 23:02:05 1996

rpm-2.3-1 Thu Dec 26 23:01:51 1996

pgp-2.6.3usa-2 Tue Oct 22 19:39:09 1996

...

 pamconfig-0.50-5 Tue Oct 15 17:23:22 1996

setup-1.5-1 Tue Oct 15 17:23:21 1996

#

By having RPM include the installation time in numeric form, it was simple to sort the packages and then use sed to remove the user-unfriendly numeric time.

Page 78

5.3.7. Finding the Largest Installed Packages

Let's say that you're running low on disk space and you'd like to see what packages you have installed, along with the amount of space each package takes up. You'd also like to see the largest packages first so you can get back as much disk space as possible:


# rpm -qa --queryformat\

> `%{name}-%{version}-%{release} %{size}\n'\

> | sort -nr +1

kernel-source-2.0.18-5 20608472

tetex-0.3.4-3 19757371

emacs-el-19.34-1 12259914

...

rootfiles-1.3-1 3494

mkinitrd-1.0-1 1898

redhat-release-4.0-1 22

#

If you don't build custom kernels or use TEX, it's easy to see how much space could be reclaimed by removing those packages.



Previous | Table of Contents | Next