How to extract RPM package on Linux system

In this tutorial we will learn, how to extract RPM package on Linux system. Extracting the rpm has one the important command and it will surely help you in System Administration. Many times I solved some problem which is caused by file corruption of particular package.

Here is the story from my experience.One day,my colleague contacted me for issue with yum command. The yum and rpm command both were not working.Later we found that some compiler library(.so) dependency file was also removed due to uninstall of some package in system.
The solution was to extract the rpm file of that package and copied the files to path which were missing.And yes,the issue was solved.

Extract RPM package on Linux system

rpm2cpio command is used for extracting cpio archive from RPM Package Manager (RPM) package . cpio command is for copying files to and from archives.

To extract RPM package use the below given command.The command will extract the file/directories from rpm package in current path.Hence,we suggest you to extract the rpm file in new separate directory.

rpm2cpio package-name.rpm |cpio -ivdm

Here,Options with cpio command means –
i = extract files from an archive
v = verbose
d = Create leading directories where needed
m = Retain previous file modification times when creating files

Below given is the reference from our system.In which,we are extracting vsftpd rpm package.

[root@localhost ~]# cd extract-rpm/
[root@localhost extract-rpm]# 
[root@localhost extract-rpm]# ls -l
total 156
-r--r--r--. 1 root root 158612 Mar 26 12:24 vsftpd-2.2.2-6.el6.i686.rpm
[root@localhost extract-rpm]# 
[root@localhost extract-rpm]# rpm2cpio vsftpd-2.2.2-6.el6.i686.rpm |cpio -ivdm
./etc/logrotate.d/vsftpd
./etc/pam.d/vsftpd
./etc/rc.d/init.d/vsftpd
./etc/vsftpd
./etc/vsftpd/ftpusers
./etc/vsftpd/user_list
./etc/vsftpd/vsftpd.conf
./etc/vsftpd/vsftpd_conf_migrate.sh
./usr/sbin/vsftpd
./usr/share/doc/vsftpd-2.2.2
./usr/share/doc/vsftpd-2.2.2/AUDIT
./usr/share/doc/vsftpd-2.2.2/BENCHMARKS
./usr/share/doc/vsftpd-2.2.2/BUGS
./usr/share/doc/vsftpd-2.2.2/COPYING
./usr/share/doc/vsftpd-2.2.2/Changelog
./usr/share/doc/vsftpd-2.2.2/EXAMPLE
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README.configuration
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README.configuration
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/README
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS/README
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/logins.txt
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2
./usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2/README
./usr/share/doc/vsftpd-2.2.2/FAQ
./usr/share/doc/vsftpd-2.2.2/INSTALL
./usr/share/doc/vsftpd-2.2.2/LICENSE
./usr/share/doc/vsftpd-2.2.2/README
./usr/share/doc/vsftpd-2.2.2/README.security
./usr/share/doc/vsftpd-2.2.2/REWARD
./usr/share/doc/vsftpd-2.2.2/SECURITY
./usr/share/doc/vsftpd-2.2.2/SECURITY/DESIGN
./usr/share/doc/vsftpd-2.2.2/SECURITY/IMPLEMENTATION
./usr/share/doc/vsftpd-2.2.2/SECURITY/OVERVIEW
./usr/share/doc/vsftpd-2.2.2/SECURITY/TRUST
./usr/share/doc/vsftpd-2.2.2/SIZE
./usr/share/doc/vsftpd-2.2.2/SPEED
./usr/share/doc/vsftpd-2.2.2/TODO
./usr/share/doc/vsftpd-2.2.2/TUNING
./usr/share/doc/vsftpd-2.2.2/vsftpd.xinetd
./usr/share/man/man5/vsftpd.conf.5.gz
./usr/share/man/man8/vsftpd.8.gz
./var/ftp
./var/ftp/pub
706 blocks
[root@localhost extract-rpm]# 
[root@localhost extract-rpm]# ls -l
total 168
drwxr-xr-x. 6 root root   4096 Mar 26 12:44 etc
drwxr-xr-x. 4 root root   4096 Mar 26 12:44 usr
drwxr-xr-x. 3 root root   4096 Mar 26 12:44 var
-r--r--r--. 1 root root 158612 Mar 26 12:24 vsftpd-2.2.2-6.el6.i686.rpm
[root@localhost extract-rpm]# 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.