≡ Menu

How to View and Extract Files from rpm, deb, depot and msi Packages

Question: How do I view or extract the files that are bundled inside the packages of various operating system. For example, I would like to know how to view (and extract) the content of a rpm, or deb, or depot, or msi file.

Answer: You can use tools like rpm, rpm2cpio, ar, dpkg, tar, swlist, swcopy, lessmsi as explained below.

1. RPM package in Redhat / CentOS / Fedora

Listing the files from a RPM package using rpm -qlp

RPM stands for Red Hat package manager. The following example shows how to view the files available in a RPM package without extracting or installing the rpm package.

$ rpm -qlp ovpc-2.1.10.rpm
/usr/src/ovpc/-5.10.0
/usr/src/ovpc/ovpc-2.1.10/examples
/usr/src/ovpc/ovpc-2.1.10/examples/bin
/usr/src/ovpc/ovpc-2.1.10/examples/lib
/usr/src/ovpc/ovpc-2.1.10/examples/test
.
.
.
/usr/src/ovpc/ovpc-2.1.10/pcs

Explanation of the command: rpm -qlp ovpc-2.1.10.rpm

  • rpm — command
  • q — query the rpm file
  • l — list the files in the package
  • p — specify the package name

Extracting the files from a RPM package using rpm2cpio and cpio

RPM is a sort of a cpio archive. First, convert the rpm to cpio archive using rpm2cpio command. Next, use cpio command to extract the files from the archive as shown below.

$ rpm2cpio ovpc-2.1.10.rpm | cpio  -idmv
./usr/src/ovpc/-5.10.0
./usr/src/ovpc/ovpc-2.1.10/examples
./usr/src/ovpc/ovpc-2.1.10/examples/bin
./usr/src/ovpc/ovpc-2.1.10/examples/lib
./usr/src/ovpc/ovpc-2.1.10/examples/test
.
.
.
./usr/src/ovpc/ovpc-2.1.10/pcs

$ ls .
usr

2. Deb package in Debian

deb is the extension of Debian software package format. *.deb is also used in other distributions that are based on Debian. (for example: Ubuntu uses *.deb)

Listing the files from a debian package using dpkg -c

dpkg is the package manager for debian. So using dpkg command you can list and extract the packages, as shown below.

To view the content of *.deb file:

$ dpkg -c ovpc_1.06.94-3_i386.deb
dr-xr-xr-x root/root         0 2010-02-25 10:54 ./                                                                                          
dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/                                                                                    
dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/pkg/                                                                            
dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/pkg/lib/                                                                 
dr-xr-xr-x root/root         0 2010-02-25 10:48 ./ovpc/pkg/lib/header/                                                      
-r-xr-xr-x root/root       130 2009-10-29 17:06 ./ovpc/pkg/lib/header/libov.so                                   
.
.
.

-r-xr-xr-x root/root       131 2009-10-29 17:06 ./ovpc/pkg/etc/conf                                   
dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/pkg/etc/conf/log.conf   

Extracting the files from a debian package using dpkg -x

Use dpkg -x to extract the files from a deb package as shown below.

$ dpkg -x  ovpc_1.06.94-3_i386.deb /tmp/ov
$ ls /tmp/ov
ovpc

DEB files are ar archives, which always contains the three files — debian-binary, control.tar.gz, and data.tar.gz. We can use ar command and tar command to extract and view the files from the deb package, as shown below.

First, extract the content of *.deb archive file using ar command.

$ ar -vx ovpc_1.06.94-3_i386.deb
x - debian-binary
x - control.tar.gz
x - data.tar.gz
$

Next, extract the content of data.tar.gz file as shown below.

$ tar -xvzf data.tar.gz 
./                                                                             
./ovpc/                                                                         
./ovpc/pkg/                                                                     
./ovpc/pkg/lib/                                                             
./ovpc/pkg/lib/header/                                                      
./ovpc/pkg/lib/header/libov.so                                   
.
.
./ovpc/pkg/etc/conf                                   
./ovpc/pkg/etc/conf/log.con

3. Depot package in HP-UX

Listing the files from a depot package using tar and swlist

DEPOT file is a HP-UX Software Distributor Catalog Depot file. HP-UX depots are just a tar file, with some additional information as shown below.

$ tar -tf ovcsw_3672.depot
OcswServer/MGR/etc/
OcswServer/MGR/etc/opt/
OcswServer/MGR/etc/opt/OV/
OcswServer/MGR/etc/opt/OV/share/
OcswServer/MGR/etc/opt/OV/share/conf/
OcswServer/MGR/etc/opt/OV/share/conf/OpC/
OcswServer/MGR/etc/opt/OV/share/conf/OpC/opcctrlovw/

swlist is a HP-UX command which is used to display the information about the software. View the content of the depot package as shown below using swlist command.

$ swlist -l file -s /root/ovcsw_3672.depot
# Initializing...
# Contacting target "osgsw"...
#
# Target:  osgsw:/root/ovcsw_3672.depot
#

# OcswServer			8.50.000       Ocsw  Server product
# OcswServer.MGR     		9.00.140       Ocs Server Ovw
  /etc
  /etc/opt
  /etc/opt/OV
  /etc/opt/OV/share
  /etc/opt/OV/share/conf
  /etc/opt/OV/share/conf/OpC

Extracting the files from a depot package using swcopy

Swcopy command copies or merges software_selections from a software source to one or more software depot target_selections. Using uncompress option in swcopy, you can extract the files from a depot software package.

$ swcopy -x uncompress_files=true -x enforce_dependencies=false -s /root/ovcsw_3672.depot \* @ /root/extracted/
$ ls /root/extracted
MGR	catalog	 osmsw.log
$

Since depot files tar files, you can extract using normal tar extraction as shown below.

$ tar -xvf filename

4. MSI in Windows

Microsoft installer is an engine for the installation, maintenance, and removal of software on windows systems.

Listing the files from a MSI package using lessmsi

The utility called lessmsi.exe is used to view the files from the msi packages with out installing. The same utility is also used to extract the msi package. Select the msi which you want to view the content. lessmsi will list the files available in msi.

Extracting the files from a MSI package using msiexec

Windows Installer Tool (Msiexec.exe) is used to extract the files from the MSI package. It can open a MSI package in “Administrator” installation mode, where it can extract the files without performing the install as shown below.

C:\>msiexec /a ovcsw_3672.msi /qb TARGETDIR="C:\ovcsw"
Add your comment

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

Comments on this entry are closed.

  • pupu April 19, 2010, 2:37 am

    Nice summary, thanks. When I want to take a look at a content of rpm, I usually use Midnight Commander (mc). It knows how to open rpm files; they look like directories and mc allows you to not only to browse cpio archives, but also pre/postinstall scripts, changelogs etc.

  • Desidia April 19, 2010, 2:46 am

    Hello,

    Good compilation. Maybe usefull when you’re on a system where you don’t have your favorite tools, but, IMHO, the easiest way to access these things is Midnight Commander (at least for rpm’s, deb’s and tgz).

    Regards,

  • Ganesh Iyer April 19, 2010, 10:53 pm

    You can use 7zip to uncompress an MSI Package.

  • Jeffrey April 21, 2010, 2:49 am

    Is there a way of just extracting a particular file from an RPM ? (on Red hat linux)
    I have not found a way for this yet.
    rpm2cpio | cpio -idmv
    will actually extract all the files from the RPM and place it in the current working directory.

  • Sasikala April 22, 2010, 1:15 am

    @Jeffrey,
    To extract a single file from rpm,

    rpm2cpio rpmname | cpio -ivd ./absolute path of the file in a RPM

    Example:
    RPM is /tmp/set-ex-5.10.0-1.i486.rpm which has a file called /usr/src/examples/set-5.10.0/ex/newconfig.set

    Now go to /tmp directory and execute the following command,

    rpm2cpio set-ex-5.10.0-1.i486.rpm | cpio -ivd ./usr/src/examples/set-5.10.0/ex/newconfig.set

    File newconfig.set is available in /tmp/usr/src/examples/set-5.10.0/ex/newconfig.set.

  • Catalin April 27, 2010, 5:28 am

    What is diff between rpm and deb packages ?
    How i make deb and rpm packages if i have make a software ?

  • dagon July 1, 2011, 7:32 am

    Nice article thanks. I searched for the dpkg -x.

  • Reureu December 20, 2011, 1:05 am

    On Windows, Orca allows to explore/edit MSI packages, so it is a bit more than just a way to extract files.

    Orca is part of the Windows SDK.

  • Fitrianto Halim April 29, 2016, 10:49 am

    Nice article.
    I’ve installed kbox on android.
    On dpkg,I can’t see options you wrote,but I can see those options on dpkg-deb .
    But,I can’t extract it if that file has symlink,for example: ./data/dalvik-cache to /android_root/data/dalvik-cache .
    If only to view deb file,we can use ZArchiver on android.
    Thanks…