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
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 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
To get a better view of the extracted files, list the contents of the directory in a tree format, run:
$ tree data
Conclusion
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.