Maximum RPM: Taking the Red Hat Package Manager to the Limit | ||
---|---|---|
Prev | Chapter 5. Getting Information About Packages | Next |
Below are 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!
You're setting up a new system, and you'd like to implement some system-wide aliases for people using the Bourne Again SHell, bash. The problem is you just can't remember the name of the system-wide initialization file used by bash, or where it resides:
# rpm -qcf /bin/bash /etc/bashrc # |
Practically any option can be combined with -qp to extract information from a .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.
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 # |
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 # |
You remember installing 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 # |
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 # |
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 # |
[1] | 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. |