How to extract a .deb file without opening it on Debian or Ubuntu Linux
-
by cobra_admin
- 288
Idownloaded a .deb Debian file. How do I extract deb package without installing it on my Debian or Ubuntu Linux based system? How do I list and extract the contents of a Debian package?
A Debian or Ubuntu .deb package is nothing but old good Unix ar archive format. The ar command is used to keep together groups of files as a single archive and .deb includes the following three files:
- debian-binary – A text file indicating the version of the .deb package format.
- control.tar.gz – A compressed file and it contains md5sums and control directory for building package.
- data.tar.xz – A compressed file and it contains all the files to be installed on your system.
Let us see how to list and extract the contents of a .deb package file on Debian/Mint/Ubuntu Linux using various command line options.
Related: How To: Extract an RPM Package Files Without Installing It On RHEL/CentOS/Fedora Linux
| Tutorial details | |
|---|---|
| Difficulty level | Easy |
| Root privileges | Yes |
| Requirements | Linux terminal |
| Category | Package Manager |
| OS compatibility | Debian • Linux • Mint • Pop!_OS • Ubuntu |
| Est. reading time | 4 minutes |
Step 1 – Download .deb package for extracting the .deb file
Use the apt-get command/apt command as follows to download a file named nginx*.deb:$ apt download nginx
OR$ aptitude download nginx
OR$ apt-get download nginx
Sample outputs:
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 nginx all 1.18.0-0ubuntu1.3 [3,620 B] Fetched 3,620 B in 1s (5,088 B/s)
To list file use the ls command:$ ls *.deb
nginx_1.18.0-0ubuntu1.3_all.deb
Step 2 – Extract .deb package using ar command
The syntax is as follows to extract .deb file on Ubuntu or Debian Linux:$ ar x {file.deb}
Installing the ar command
You can install ar command using the following apt-get command/apt command. For example:$ sudo apt install binutils
OR$ sudo apt-get install binutils
Sample outputs:
Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: binutils-doc The following NEW packages will be installed: binutils 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 2,310 kB of archives. After this operation, 13.6 MB of additional disk space will be used. Get:1 http://in.archive.ubuntu.com/ubuntu xenial-updates/main amd64 binutils amd64 2.26.1-1ubuntu1~16.04.3 [2,310 kB] Fetched 2,310 kB in 6s (343 kB/s) Selecting previously unselected package binutils. (Reading database ... 92869 files and directories currently installed.) Preparing to unpack .../binutils_2.26.1-1ubuntu1~16.04.3_amd64.deb ... Unpacking binutils (2.26.1-1ubuntu1~16.04.3) ... Processing triggers for libc-bin (2.23-0ubuntu5) ... Processing triggers for man-db (2.7.5-1) ... Setting up binutils (2.26.1-1ubuntu1~16.04.3) ... Processing triggers for libc-bin (2.23-0ubuntu5) ...
To extract nginx_1.18.0-0ubuntu1.3_all.deb, run:$ ar vx nginx_1.18.0-0ubuntu1.3_all.deb
$ ls -l
Fig.01: How to extract deb package
Extract files from control.tar.gz and data.tar.gz
Type the following tar command to extract tarball. For example:$ tar xvf control.tar.gz
$ tar data.tar.gz
$ ls -l
All files are extracted into the current directory.
Say hello to dpkg-deb command
You can use the dpkg-deb command to extract .deb file too. The syntax is:$ dpkg-deb -xv {file.deb} {/path/to/where/extract}
To extract htop_2.0.1-1ubuntu1_amd64.deb in the /tmp/ directory run:$ dpkg-deb -xv htop_2.0.1-1ubuntu1_amd64.deb /tmp/
To extract htop_2.0.1-1ubuntu1_amd64.deb in the current directory run:$ dpkg-deb -xv htop_2.0.1-1ubuntu1_amd64.deb .
Sample session:
Fig.02: To extract files from a Debian package use dpkg-deb command
How do I view contents of a Debian package without extracting it?
The syntax is:$ dpkg -c {file.deb}
OR$ apt-file list {packageName}
For example to view contents of a Debian package named htop_2.0.1-1ubuntu1_amd64.deb, run:$ dpkg -c htop_2.0.1-1ubuntu1_amd64.deb
Sample outputs:
Fig.03: View contents of a Debian or Ubuntu Linux .deb package using dpkg command
You can also use apt-file command as follows
The apt-file is not installed by default. So install it and use it as follows:$ sudo apt-get install apt-file ## install ##
$ sudo apt-file update ## update package cache ##
$ apt-file list htop ## list htop package contents ##

Fig.04: Using apt-file to view the contents of debian packages
Summing up
And that is we extract .deb file or view contents of downloaded .deb files on Debian or Ubuntu Linux. For more info see the following man pages documents using the help command or man command:$ man ar
$ man dpkg
$ man dpkg-deb
Idownloaded a .deb Debian file. How do I extract deb package without installing it on my Debian or Ubuntu Linux based system? How do I list and extract the contents of a Debian package? A Debian or Ubuntu .deb package is nothing but old good Unix ar archive format. The…
Idownloaded a .deb Debian file. How do I extract deb package without installing it on my Debian or Ubuntu Linux based system? How do I list and extract the contents of a Debian package? A Debian or Ubuntu .deb package is nothing but old good Unix ar archive format. The…