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:
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:
To extract nginx_1.18.0-0ubuntu1.3_all.deb, run:$ ar vx nginx_1.18.0-0ubuntu1.3_all.deb
$ ls -l
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: