RPM package queries
This post is just a quick walk-through of some basic commands to help you find information about
These commands will work for any rpm based distribution (Red Hat, Centos, Suse, Mageia).
Debian based distributions like Ubuntu or Mint use
dpkg instead of
rpm and I'll cover those in a different post.
Query the rpm database
You can query the
rpm database to find a particular installed package using the
rpm -q you must also pass a package name. For example, to find out what version of the
httpd server we have installed we can use
rpm -q httpd/
rpm -q httpd
List all installed packages
To get a quick list of every installed package on an
rpm based Linux distribution you can use
In this case you do not need to pass any specific package into the command. Often times you will use this to find a package when you are not sure of the exact name. For example, you might
ruby to find all the installed
rpm -qa | grep ruby will produce output similar to this on a Centos 7 server.
rpm -qa | grep ruby
Find associated files
rpm -ql and
rpm -qc will help you to locate files associated with a particular package.
This is a great tool to help you find your way around a newly installed application. For example, how could you find out that the configuration file for Apache can be found at
/etc/httpd/conf/httpd.conf, without searching the interwebs?
rpm -qc httpd will list all of the configuration files.
rpm -qc httpd
rpm -ql will give you a list not only of configuration files but also every file that was installed on your server with its location.
In some cases, you may need more information about a package. Who is the vendor? When was it installed? etc... Getting this type of information with
rpm packages is easy.
rpm -qi httpd
Name : httpd
Version : 2.4.6
Release : 45.el7.centos.4
Install Date: Mon 12 Jun 2017 09:37:04 PM UTC
Group : System Environment/Daemons
Size : 9823677
License : ASL 2.0
Signature : RSA/SHA256, Thu 13 Apr 2017 01:04:44 AM UTC, Key ID 24c6a8a7f4a80eb5
Source RPM : httpd-2.4.6-45.el7.centos.4.src.rpm
Build Date : Wed 12 Apr 2017 09:05:23 PM UTC
Build Host : c1bm.rdu2.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://httpd.apache.org/
Summary : Apache HTTP Server
The Apache HTTP Server is a powerful, efficient, and extensible
You can also quickly find where documentation for a package can be found on your system using
rpm -qd httpd
This documentation will include listing
man pages that might be available. As well as example configuration files. In this case you can see that
/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf is an example of a virtual host file.... Maybe something that would come in handy as a template for virtual hosts you might have to set up.
As you can see there is quite a lot of information that can be extracted from the rpm database. In my humble opinion, this is one of the big advantages that
rpm has over
dpkg (though you can get this information from
dpkg, it's just not as straight forward),
rpm makes it easy to query the database and quickly find the information you need.
All of this really only scratches the surface of what you can do as well. There are many ways to modify these commands to help you discover information about the packages you have installed on your system. I encourage you to read the full
man page for
rpm if you are interested in learning more in-depth capabilities for