RPM query to find documents and config files for a package

When I started this blog, my first post was Where do commands in Linux come from? Today, I want to revisit some rpm commands that are very useful to find out more about a package.

For example, which package provides the cron service?

# rpm -qf `which crond`
cronie-1.4.11-14.el7_2.1.x86_64

In RHEL 7, cron is provided by the package cronie. The yum way would be

yum provides */crond  or
yum whatprovides */crond

What are the various files that come with this package?

# rpm -ql cronie
/etc/cron.d
/etc/cron.d/0hourly
/etc/cron.deny
/etc/pam.d/crond
/etc/sysconfig/crond
/usr/bin/crontab
/usr/lib/systemd/system/crond.service
/usr/sbin/crond
/usr/share/doc/cronie-1.4.11
/usr/share/doc/cronie-1.4.11/AUTHORS
/usr/share/doc/cronie-1.4.11/COPYING
/usr/share/doc/cronie-1.4.11/ChangeLog
/usr/share/doc/cronie-1.4.11/INSTALL
/usr/share/doc/cronie-1.4.11/README
/usr/share/man/man1/crontab.1.gz
/usr/share/man/man5/crontab.5.gz
/usr/share/man/man8/cron.8.gz
/usr/share/man/man8/crond.8.gz
/var/spool/cron

What are the configuration files for cron?

# rpm -qc cronie
/etc/cron.d/0hourly
/etc/cron.deny
/etc/pam.d/crond
/etc/sysconfig/crond

What are the man pages, documents for this package?

# rpm -qd cronie
/usr/share/doc/cronie-1.4.11/AUTHORS
/usr/share/doc/cronie-1.4.11/COPYING
/usr/share/doc/cronie-1.4.11/ChangeLog
/usr/share/doc/cronie-1.4.11/INSTALL
/usr/share/doc/cronie-1.4.11/README
/usr/share/man/man1/crontab.1.gz
/usr/share/man/man5/crontab.5.gz
/usr/share/man/man8/cron.8.gz
/usr/share/man/man8/crond.8.gz

Usually, an rpm package comes with script. This is how you can check the script.

# rpm -q --scripts  cronie
postinstall scriptlet (using /bin/sh):
# run after an installation

if [ $1 -eq 1 ] ; then
        # Initial installation
        systemctl preset crond.service >/dev/null 2>&1 || :
fi
preuninstall scriptlet (using /bin/sh):
# run before a package is removed

if [ $1 -eq 0 ] ; then
        # Package removal, not upgrade
        systemctl --no-reload disable crond.service > /dev/null 2>&1 || :
        systemctl stop crond.service > /dev/null 2>&1 || :
fi
postuninstall scriptlet (using /bin/sh):
# run after a package is removed

systemctl daemon-reload >/dev/null 2>&1 || :
if [ $1 -ge 1 ] ; then
        # Package upgrade, not uninstall
        systemctl try-restart crond.service >/dev/null 2>&1 || :
fi

The above commands will not work if you query a package that is not installed.

# rpm -ql sshpass-1.05-5.el7.x86_64.rpm
package sshpass-1.05-5.el7.x86_64.rpm is not installed

To query a package that is not installed, add the -p flag for package.

# rpm -qpl sshpass-1.05-5.el7.x86_64.rpm
warning: sshpass-1.05-5.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
/usr/bin/sshpass
/usr/share/doc/sshpass-1.05
/usr/share/doc/sshpass-1.05/AUTHORS
/usr/share/doc/sshpass-1.05/COPYING
/usr/share/doc/sshpass-1.05/ChangeLog
/usr/share/doc/sshpass-1.05/NEWS
/usr/share/man/man1/sshpass.1.gz
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s