This short post shows few examples how to manage software packages from the cli by using the yum and rpm utility.

RPM queries

Show packages in the rpm database:

[[email protected] ~]# rpm -qa
libnice-0.1.3-4.el7.x86_64
mozjs24-24.2.0-6.el7.x86_64
telepathy-haze-0.8.0-1.el7.x86_64
[. . .]

Show packages in the rpm database:

[[email protected] ~]# rpm -qa | grep bash
bash-completion-2.1-6.el7.noarch
bash-4.2.46-21.el7_3.x86_64

List files in the rpm package:

[[email protected] ~]# rpm -ql bash-completion
/etc/bash_completion.d
/etc/bash_completion.d/redefine_filedir
/etc/profile.d/bash_completion.sh
/usr/share/bash-completion
/usr/share/bash-completion/bash_completion
/usr/share/bash-completion/completions
[. . .]
/usr/share/pkgconfig/bash-completion.pc

List files in the rpm package:

[[email protected] etc]# rpm -ql libnfsidmap 
/etc/idmapd.conf
/lib64/libnfsidmap.so.0
/lib64/libnfsidmap.so.0.3.0
/lib64/libnfsidmap/nsswitch.so
/lib64/libnfsidmap/static.so
/lib64/libnfsidmap/umich_ldap.so
/usr/share/doc/libnfsidmap-0.25
/usr/share/doc/libnfsidmap-0.25/AUTHORS
/usr/share/doc/libnfsidmap-0.25/COPYING
/usr/share/doc/libnfsidmap-0.25/ChangeLog
/usr/share/doc/libnfsidmap-0.25/NEWS
/usr/share/doc/libnfsidmap-0.25/README
/usr/share/man/man3/nfs4_uid_to_name.3.gz
/usr/share/man/man5/idmapd.conf.5.gz

Find rpm package given files are coming from:

[[email protected] etc]# rpm -qf /etc/idmapd.conf
libnfsidmap-0.25-15.el7.x86_64

Find the rpm package configuration file(s):

[[email protected] etc]# rpm -qc libnfsidmap
/etc/idmapd.conf

Find the rpm package documentation files:

[[email protected] etc]# rpm -qd libnfsidmap
/usr/share/doc/libnfsidmap-0.25/AUTHORS
/usr/share/doc/libnfsidmap-0.25/COPYING
/usr/share/doc/libnfsidmap-0.25/ChangeLog
/usr/share/doc/libnfsidmap-0.25/NEWS
/usr/share/doc/libnfsidmap-0.25/README
/usr/share/man/man3/nfs4_uid_to_name.3.gz
/usr/share/man/man5/idmapd.conf.5.gz

Query packages in repositories

How to query an rpm package before installing it?

Query repository:

[[email protected] etc]# repoquery nginx
nginx-1:1.10.2-1.el7.x86_64

Get info about the package:

[[email protected] etc]# repoquery -i nginx

Name        : nginx
Version     : 1.10.2
Release     : 1.el7
Architecture: x86_64
Size        : 1459372
Packager    : Fedora Project
Group       : System Environment/Daemons
URL         : http://nginx.org/
Repository  : epel
Summary     : A high performance web server and reverse proxy server
Source      : nginx-1.10.2-1.el7.src.rpm
Description :
Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
IMAP protocols, with a strong focus on high concurrency, performance and low
memory usage.

List the package content:

[[email protected] etc]# repoquery -l nginx
/etc/logrotate.d/nginx
/etc/nginx/fastcgi.conf
/etc/nginx/fastcgi.conf.default
[. . .]
var/log/nginx

Download rpm package and check scripts included in the rpm:

Note: It is especially useful if we have the rpm package downloaded from not reliable source and we want to check what scripts would be executed when installing the package.

[[email protected] etc]# yumdownloader httpd
[[email protected] etc]# ls -lt | grep httpd
-rw-r--r--.  1 root root   2831588 Apr 13 02:04 httpd-2.4.6-45.el7.centos.4.x86_64.rpm
[[email protected] etc]# rpm -qpi httpd-2.4.6-45.el7.centos.4.x86_64.rpm
Name        : httpd
Version     : 2.4.6
Release     : 45.el7.centos.4
Architecture: x86_64
Install Date: (not installed)
Group       : System Environment/Daemons
Size        : 9823677
License     : ASL 2.0
Signature   : RSA/SHA256, Thu 13 Apr 2017 02:04:44 IST, Key ID 24c6a8a7f4a80eb5
Source RPM  : httpd-2.4.6-45.el7.centos.4.src.rpm
Build Date  : Wed 12 Apr 2017 22:05:23 IST
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
Description :
The Apache HTTP Server is a powerful, efficient, and extensible
web server.

List files in the rpm package:

[[email protected] etc]# rpm -qpl httpd-2.4.6-45.el7.centos.4.x86_64.rpm 
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.d/README
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
[. . .]
/var/www/cgi-bin
/var/www/html