Sharing Knowledge | System Admin Articles

Quick HOWTO: View contents of RPM without installing it

In Linux, You may wonder what are the files inside a rpm package and you may want to check them before installing it.

You can do this with the below rpm commands:

If the rpm file available locally:
[root@linux_server1 ~]# rpm -qlp telnet-0.17-48.el6.x86_64.rpm
/usr/bin/telnet
/usr/share/man/man1/telnet.1.gz
[root@linux_server1 ~]#

[root@linux_server1 ~]# rpm -q -filesbypkg -p numactl-devel-2.0.9-2.el6.x86_64.rpm
numactl-devel             /usr/include/numa.h
numactl-devel             /usr/include/numacompat1.h
numactl-devel             /usr/include/numaif.h
numactl-devel             /usr/lib64/libnuma.a
numactl-devel             /usr/lib64/libnuma.so
[root@linux_server1 ~]#

If you want to check the contents of a rpm located in a remote repository:
[root@linux_server1 ~]# repoquery --list telnet
/usr/bin/telnet
/usr/share/man/man1/telnet.1.gz
[root@linux_server1 ~]#

If you want to check the pre installation and post installation scripts which runs while you installing a rpm package.
[root@linux_server1 ~]# rpm -qp --scripts sysstat-9.0.4-33.el6.x86_64.rpm
postinstall scriptlet (using /bin/sh):
/sbin/chkconfig --add sysstat
preuninstall scriptlet (using /bin/sh):
if [ "$1" = 0 ]; then
  # Remove sa logs if removing sysstat completely
  rm -f /var/log/sa/*
  # Remove service
  /sbin/chkconfig --del sysstat
fi
[root@linux_server1 ~]#

If the rpm is already installed, you can use same commands without passing the arguement "-p".

Example:
rpm -ql sysstat-9.0.4-33.el6.x86_64
rpm -q --scripts sysstat-9.0.4-33.el6.x86_64


If you want to extract the rpm contents without installing it.
root@linux_server1~]# rpm2cpio telnet-0.17-48.el6.x86_64.rpm | cpio -idmv
./usr/bin/telnet
./usr/share/man/man1/telnet.1.gz
220 blocks

Labels: Linux, Quick HOWTO, RHEL
2 Comments for "Quick HOWTO: View contents of RPM without installing it"

Hello just wanted to give you a quick heads up and let you know a few of the pictures aren't loading correctly.
I'm not sure why but I think its a linking issue.
I've tried it in two different browsers and both show the same results.

Hi,

Thanks for letting us know. We will check on this.

What do you think about this Article? Add your Opinion..!

Back To Top