Team LiB
Previous Section Next Section

Querying Software Packages

With the rpm query feature, you can display many details about the form and content of the RPM packages in your Linux system. You can then output that information in any way that is useful to you. Querying can be done on individual packages or over the entire RPM database.

Querying Local or Remote Packages

For each of the following query options, if you give the RPM package's base name, rpm will query the database for information about that installed package. If you want to query a package that is not installed, you must use the -p option followed by the package name (in the current directory), the full path to the package name, or a URL to the package. For example, to see the description for a mozilla package in my current directory, I could type

   # rpm -qi -p mozilla-1.4.1-17.i386.rpm

A package may also be contained on a website (HTTP) or FTP server. Here is an example of the rpm command being used to list the contents of an RPM on a remote FTP site. The following example displays all files contained in the apt package from the ftp.freshrpms.net shown (the entire command should be on one line):

   # rpm -ql -p ftp://ftp.freshrpms.net/pub/freshrpms/fedora/linux/1/apt/apt-0.5.lcnc3-
    0.1.fr.i386.rpm

The -p option provides a good way to check out packages on remote systems before you install them. If a username and password are required, they can be added to the command line. In this example, the user is tina and the password is my44hat as follows:

   # rpm -ql -p ftp://tina:my44hat@ftp.example.net/pub/any.rpm

Querying Individual Packages

You can find out a lot of information for any rpm package installed on your system. Here are a few examples:

  • All files in a package-Use the -ql option to display all the files in a package. In the following example, we query a package that is installed on the computer:

    #rpm -ql samba | less
    /etc/logrotate.d/samba
    /etc/pam.d/samba
    /etc/rc.d/init.d/smb
    /etc/samba/smbusers
    

    Here you can page through all the files contained in the samba package.

  • Documentation in a package-Instead of listing all the files (-ql), you can list only documentation files contained in a package using the -qd option. For example,

    #rpm -qd bind-utils
    /usr/share/man/man1/dig.1.gz
    /usr/share/man/manl/host.l.gz
    /usr/share/man/man5/resolver.5.gz
    /usr/share/man/man8/nslookup.8.gz
    /usr/share/man/man8/nsupdate.8.gz
    

    This shows that the bind-utils package contains documentation in the form of five man pages (for example, type man dig to see the first one). Besides man pages, packages often include documentation that comes in Texinfo format (type info) and files in /usr/share/doc for the package.

  • Configuration files in a package-You can list configuration files associated with a package with the -qc option. Most packages will keep their configuration files in /etc (or a subdirectory of /etc).

    #rpm -qc samba
    /etc/logrotate.d/samba
    /etc/pam.d/samba
    /etc/rc.d/init.d/smb
    /etc/samba/smbusers
    /etc/sysconfig/samba
    

    Sometimes the -qc option will turn up files in locations outside of /etc that you might want to reconfigure. For example, the httpd package lists files in the /var/www/error directory you could change if you want different information displayed by your Apache web server for different error conditions.

  • Changelog for a package-To see changelog entries made to an RPM package, you can use the --changelog query option. If the software developer has been verbose about his updates, this information can help you understand what has been done to the package lately. For example,

    # rpm -q --changelog XFree86 | less
    * Mon Oct 20 2003 Mike A. Harris <mharris@redhat.com> 4.3.0-42
    
    - This release is the long awaited answer to the meaning of life, the
      universe and everything.
    - Added XFree86-4.3.0-redhat-exec -shield-GNU-stack.patch to make the
      complete Xlree86 build including Mesa et al. exec-shield friendly
      (arjanv, mharris)
    - Updated to new XFree86-4.3.0-Mesa-SSE-fixes from-MesaCVS-v2.patch which
      should fix compatibility problems between DRI and 2.6.x kernels which
    :
    
  • Description of a package-A formatted set of information about a package can be displayed using the -qi option. Here's an example:

    # rpm -qi XFree86
    Name        : XFree86          Relocations: (not relocateable)
    Version     : 4.3.0                 Vendor: Red Hat, Inc.
    Release     : 42                Build Date: Fri 24 Oct 2003 03:19:36 PM PDT
    Install Date: Tue 11 Nov 2003 04:26:51 PM PST Build Host: porky.redhat.com
    Group       : User Interface/X     Source RPM: XFree86-4.3.0-42.src.rpm
    Size        : 64230/11                         License: XFree86
    Signature   : DSA/SHA1, Tue 28 Oct 2003 04:20:58 PM PST, Key ID
                  b44269d04r2a6fd2
    Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
    URL         : http://www.xfree86.org
    Summary     : The basic fonts, programs and does for an X workstation. Description:
    XFree86 is an open source implementation of the X Window System. It
    provides the basic low level functionality which full fledged
    graphical user interfaces (GUIs) such as GNOME and KDE are designed upon.
    
  • Name of a package-Say that you are looking for a package that has the characters "bind" in it, but you can't remember the package's exact name. The -qa option lets you list all packages, from which you can then search for the string of characters that interests you. Here's an example:

    # rpm -qa *bind*
    bind-utils-9.2.2.P3-9
    kdebindings-devel-3.1.4-1
    redhat-config-bind-2.0.0-18
    bind-chroot-9.2.2.P3-9
    bind-devel-9.2.2.P3-9
    kdebindings-3.1.4-1
    ypbind-1.12-3
    bind-9.2.2.P3-9
    

Querying Multiple Packages

The content of an RPM package consists of a header, signatures, and the actual files that you are installing from the RPM. Each piece of information in the header is marked with a tag. When you query an RPM package, you are inquiring about the content of one or more of these tags.

The rpm command lets you query the RPM database for tags that you request and then displays the resulting information in a format that you choose. This section provides some useful examples of the rpm query feature for finding and displaying information for multiple RPM files.

You can start out by listing all the query tags that may be available in RPMs on your computer. You do that as follows:

   # rpm --querytags | less

This example lets you page through the list of tags. 1 counted 139 tags available on my Fedora Core 1 system. Any of the tags that interest you can be put in an rpm query command so that information from those tags can be displayed in the format you choose. Here are some examples:

  • To display the name and summary information for every package beginning with the string XFree86, you could type the following:

    # rpm -qp --queryformat "%{NAME} *** %{SUMMARY) \ n" XFree86*
    XFree86-base-fonts *** The collection of XFree86 base fonts
    XFree86-tools *** Various tools for XFree86
    XFree86-IS08859-14-100dpi-fonts *** IS08859-14-100dpi-fonts
    XFree86-font-utils *** Utilities required for installing fonts
    
  • To list the name of every package along with the web address (URL) to the package's website, you could type the following rpm command. This command is piped to the less command, which lets you page through the output.

    # rpm -qp --queryformat "%{NAME} >>> %{URL} \ n" | less
    libattr >>> http://acl.bestbits.at/
    mktemp >>> http://www.mktemp.org
    less >>> http://www.greenwoodsoftware.com/less/
    shadow-utils >>> http://shadow.pld.org.pl/
    pam >>> http://www.us.kernel.org/pub/linux/libs/pam/index.html
    rmt >>> http://dump.sourceforge.net
    zip >>> http://www.info-zip.org/pub/infozip/Zip.html
    logwatch >>> http://www.logwatch.org/
    bind-utils >>> http://www.isc.org/products/BIND/
    libxml2-python >>> http://xmlsoft.org/
    
  • In the following example, the installed RPM database is queried, then the output is in the form of P: followed by the package name, then S: followed by the summary line for the package. Finally, the output is piped to the grep command, which displays only those lines that contain the term image.

    # rpm -qp --queryformat "P: %{NAME} S: %{SUMMARY} \ n" | grep -i image
    P: desktop-backgrounds-extra S: Desktop background images.
    P: SDL_image-devel S: Development files for the SDL image loading library.
    P: gimp S: the GNU Image Manipulation Program.
    

Team LiB
Previous Section Next Section