Linux+: Applications 02 – RPM Package Query

J

Jarret W. Buse

Guest
Linux+: Applications 02 – RPM Package Query

In the first article of the Linux+ Applications section I covered the RPM modes of Install, Update, Freshen and Remove. In this article, I will cover the details about Querying the packages.

NOTE:
Do not confuse RPM with Yum. Yum is a command-line front-end for RPM. Apper and other such programs
are a GUI front-end for both.

This article covers the use of RPM from a command-line. It is assumed that any packages, files with an extension of RPM, are located locally on the system. The Yum utility and Apper GUI is used to actually perform downloading of the package to the local system. Once the package is downloaded locally, Yum or Apper calls RPM in the background to perform the actual desired command on the package.

The query ability of RPM is used to determine what packages are installed on a system.
The basic syntax for RPM to query installed packages are:

RPM -q select_options query_options
RPM --query select_options query_options


The “select_options” are as follows:

  • PACKAGE_NAME – queries the package given by PACKAGE_NAME
  • -a (--all) – Queries all the installed packages
  • -f (--file FILE) – queries the package owning the specified FILE
  • --fileid MD5 – queries package with given file identifier MD5
  • -g (--group GROUP_NAME) – queries packages within the group GROUP_NAME
  • -p (--package PACKAGE_FILE) – query uninstalled package of PACKAGE_NAME
  • --hdrid SHA1- query package with header identifier given as SHA1
  • --pkgid MD5 – queries package with package identifier of MD5
  • --tid TID – queries packagaes with transaction identifier of TID
  • --querybynumber HDRNUM – queries the entry number of a database given by the entry number of HDRNUM
  • --triggeredby PACKAGE_NAME – queries the packages which are triggered by the PACKAGE_NAME
  • --whatprovides CAPABILITY – query all packages which provide the given CAPABILITY
  • --whatrequires CAPABILITY – query all packages which require the CAPABAILITY to function properly

The “query_options” are as follows:

  • -c (--configfiles) – list configuration files for the given package
  • -d (--docfiles) – display list of documentation files for package
  • --dump – show more information on files
  • --filesbypkg – lists files in package
  • -i (--info) – displays more package information than normal
  • --last – change output order to newest first and oldest last
  • -l (--list) - displays the file list of the package contents
  • --provides – lists capabilities which each package provides
  • --qf (--queryformat QUERYFMT) – use specified format for query output
  • -R (--requires) – shows list of package dependencies
  • --scripts – diplays scripts in the package
  • -s (--state) – shows the state of the listed files
  • --triggers (--triggerscripts) – shows trigger scripts in the package

To perform a basic listing of all installed packages, the command would be “rpm -q -a”. It would be necessary to pipe the information through a utility such as “less” to help improve readability by using: “rpm -q -a | less”.

If you needed to verify a specific package was installed, such as a package named “Application1”, you would use the command: “rpm -q Application1”. If any results are displayed, the package is installed. If no results are shown, the package is not installed on the system.

NOTE: Be aware that a query in this manner requires the proper name of the package. If the installed package were called “Application-1.234-x86-64” the query would not find it. To be certain, use the command “rpm -qa | grep APP_NAME”. The results, if they exist, should be a better listing if the name is not completely correct.

If you should need more detailed information about an installed package, use the command “rpm -qi PACKAGE_NAME”. Again, the package name must be exact. If needed, get a full list of packages (“rpm -qa”) and use the proper name given. The details given include:

  • Version
  • Release
  • Installation Date
  • Size
  • and much more information

Configuration files (.conf) can belong to any package. Of course, some are easy to determine which package they belong to on the system. If you are not sure, use the command “rpm -qf CONF_FILE”. The path to the configuration and its name must be given, but the result displayed should show the package from which it was installed.

If you have a package and wish to see what configuration files are on the system from the package, use the command “rpm -qc PACKAGE_NAME”. The configuration files, if any, should be displayed.

Most packages will contain and install documentation files. If you need to find the documentation files which the package installed, use the command “rpm -qd PACKAGE-NAME”.

Sometimes, you may need to know all the files installed by the package. To gather this information, use “rpm -ql PACKAGE_NAME”. A listing of all the installed files should be displayed.

To determine any dependencies needed for the package, use “rpm -qR PACKAGE_NAME”.

These are the basic options for the query mode. The RPM command is a very powerful command and usually not understood since it is commonly used through Yum. It is best to be comfortable with the RPM command before taking the Linux+ exam.
 

Attachments

  • slide.jpg
    slide.jpg
    32.9 KB · Views: 15,445


Top