Extracting Debian/Ubuntu .deb package with ar command

Fig.01: How to extract deb package

Fig.01: How to extract deb package

To extract deb package on Debian or Ubuntu or Mint Linux use the following syntax.

Install ar command

$ sudo apt-get install binutils

How to extract deb package

To extract a package named lsof, run:
$ apt-get download lsof ## download lsof package for testing ##
$ ls -l
$ ar xv lsof_4.89+dfsg-0.1_amd64.deb

Sample outputs:

x - debian-binary
x - control.tar.gz
x - data.tar.xz

View files:
$ ls -l
Sample outputs:

total 496
-rw-r--r-- 1 vivek vivek   1305 Mar  7 20:29 control.tar.gz
-rw-r--r-- 1 vivek vivek 246032 Mar  7 20:29 data.tar.xz
-rw-r--r-- 1 vivek vivek      4 Mar  7 20:29 debian-binary
-rw-r--r-- 1 vivek vivek 247530 Oct 28  2015 lsof_4.89+dfsg-0.1_amd64.deb

To extract control.tar.gz, run:
$ tar xvf control.tar.gz
Sample outputs:

./
./md5sums
./control

To extract data.tar.xz, run:
$ tar xvf data.tar.xz
Sample outputs:

./
./usr/
./usr/share/
./usr/share/doc/
./usr/share/doc/lsof/
./usr/share/doc/lsof/00LSOF-L
./usr/share/doc/lsof/README.Debian
./usr/share/doc/lsof/examples/
./usr/share/doc/lsof/examples/00MANIFEST
./usr/share/doc/lsof/examples/count_pf.perl
./usr/share/doc/lsof/examples/shared.perl5.gz
./usr/share/doc/lsof/examples/list_NULf.perl5.gz
./usr/share/doc/lsof/examples/big_brother.perl5.gz
./usr/share/doc/lsof/examples/idrlogin.perl.gz
./usr/share/doc/lsof/examples/identd.perl5
./usr/share/doc/lsof/examples/watch_a_file.perl
./usr/share/doc/lsof/examples/xusers.awk
./usr/share/doc/lsof/examples/idrlogin.perl5.gz
./usr/share/doc/lsof/examples/count_pf.perl5
./usr/share/doc/lsof/examples/list_fields.awk.gz
./usr/share/doc/lsof/examples/00README
./usr/share/doc/lsof/examples/list_fields.perl.gz
./usr/share/doc/lsof/examples/sort_res.perl5
./usr/share/doc/lsof/00QUICKSTART.gz
./usr/share/doc/lsof/00FAQ.gz
./usr/share/doc/lsof/copyright
./usr/share/doc/lsof/changelog.Debian.gz
./usr/share/man/
./usr/share/man/man8/
./usr/share/man/man8/lsof.8.gz
./usr/bin/
./usr/bin/lsof

Verify extracted files:
$ ls -l
Sample outputs:

total 508
-rw-r--r-- 1 vivek vivek    590 Oct 28  2015 control
-rw-r--r-- 1 vivek vivek   1305 Mar  7 20:29 control.tar.gz
-rw-r--r-- 1 vivek vivek 246032 Mar  7 20:29 data.tar.xz
-rw-r--r-- 1 vivek vivek      4 Mar  7 20:29 debian-binary
-rw-r--r-- 1 vivek vivek 247530 Oct 28  2015 lsof_4.89+dfsg-0.1_amd64.deb
-rw-r--r-- 1 vivek vivek   1672 Oct 28  2015 md5sums
drwxr-xr-x 4 vivek vivek   4096 Oct 28  2015 usr

You can now cd to ./usr in the current directory to see all all extracted files:
$ cd usr
$ ls

Examples and usage: How to extract a .deb file without opening it on Debian or Ubuntu Linux