Home Linux Commandline Tips How to Extract Files from a DEB Package in Debian Systems

How to Extract Files from a DEB Package in Debian Systems

Have you ever wondered how you can extract individual files from a Debian file (.deb) without actually installing any software?

In this guide, we will walk you through how you can do so using the ar and dpkg-deb command line utilities.

The Architecture of a .DEB File

A binary package (.deb) consists of the following salient files:

  • debian-binary – This is a text file that indicates the version of the .deb package format.
  • control.tar.gz – This is a compressed file that contains metadata about the Debian package. It has 3 files – the md5sums file, the control file that contains file metadata, and the postinst script file.
  • data.tar.xz – A compressed file comprising all the files that will be installed on your system.

Extracting Files From a Deb Package Using ar Command

The ar command is a utility that creates, modifies, and extracts files from their archives. An archive is basically a file that comprises multiple individual files which collectively make up a single file.

To demonstrate how you can extract files, we have downloaded a skype .deb installation file using the following wget command:

$ wget https://go.skype.com/skypeforlinux-64.deb

The ls command below confirms the existence of the .deb</code Debian file.

$ ls -l
Check Debian Package File
Check the Debian Package File

To extract the contents of the Skype Debian package, run the following ar command. The x option extracts the contents of the file while the v option displays the files extracted on the terminal.

$ ar xv skypeforlinux-64.deb

Once extracted, you can list the files using the good old ls command as shown.

$ ls -lh

You will see the control and data archives alongside the Debian-binary file which contains the metadata of the Debian file.

Extract Deb Files in Linux
Extract Deb Files in Linux

Extract Deb Package Files Using dkpg-deb Command

The dpkg-deb command is yet another utility that you can use to extract a Debian file. To extract the Skype Debian file, run the following command:

$ sudo dpkg-deb -x skypeforlinux-64.deb data

Once again, you can use the ls command to list the extracted files. Here you can see that all the files are organized into opt and usr directories.

$ ls -l
Extract Deb Package Files in Linux
Extract Deb Package Files in Linux

To get a better view of the extracted files, list the contents of the directory in a tree format, run:

$ tree data
Linux Directory Tree Listing
Linux Directory Tree Listing

That concludes this guide on how to extract files from a .deb package without actually installing the software that comes bundled with the package. We hope that you found this helpful. Your feedback will be appreciated.

Winnie Ondara
My name is Winnie, a Linux enthusiast and passionate tech writer in Linux and DevOPs topics. I enjoy keeping abreast with the latest technologies in the Linux ecosystem and trying out new tools provided by the FOSS community.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.