Friday, November 8, 2013

Checking installed packages (libraries) in RH Linux... with RPM

Before you start installing applications in Linux, as in any other system, it is essential to check the existence of all prerequisites.

Some times these prerequisites are system packages (libraries) that applications use. Usually I don't need to install them, because this is done by a System Administrators team. When I do install them, then the validation is automatically done... right? But when the installation is done by the Sys Admin team, I end up having to run the validation. A little bit of additional work, but it is always usefull.


So, how to make this validation, and check if all packages that are a requisite for your applications are available in the server? If using Red Hat Linux, just use RPM command (Red Hat Package Manager). This will list all the installed packages . 

Relevant parameters:
-q (query)
-a (all)
--qf (query format)

A simple (full) list would be obtained by querying all packages:
rpm -qa
  
Usually, I also want to know if the package is 32 or 64 bit. So I add a query format to the output, that it includes the package name, version and bit value: 
rpm -qa --qf '%{NAME}-%{VERSION} (%{ARCH})\n' | sort


The result would be something like this:

acl-2.2.39(x86_64)
acpid-1.0.4(x86_64)
alchemist-1.0.36(x86_64)
alsa-lib-1.0.17(i386)
alsa-lib-1.0.17(x86_64)
alsa-lib-devel-1.0.17(x86_64)
alsa-utils-1.0.17(x86_64)
(…)


Now you have all the information needed for this validation. Either check it on the screen, or redirect the output to a file and use it to make the validations you need.

No comments:

Post a Comment