Open cardboard box

How to download and unpack RPM packages to examine files?

When working with RPM packages on RHEL/CentOS Linux, sometimes you'd like to examine the contained files. Fortunately, it's pretty easy to unpack the RPM packages using the rpm2cpio and cpio commands. Firstly, if you don't have the package, use yumdownloader to download the package (package rsyslog taken as an example)...

1
2
3
mkdir rsyslog-rpm-package
cd rsyslog-rpm-package
yumdownloader rsyslog

Secondly, unpack and extract the files...

1
rpm2cpio rsyslog.rpm | cpio -dium

Now you should have directores like etc or usr in your current directory where you can explore (and edit if you want) the files that were inside the RPM package.