Today we’ll be discussing a rather simple subject, limited to just the curious and tinkerers, about how you extract files from .deb files. The folks who want to know this information will likely be the intellectually curious or those who are doing so for scholarly, academic approaches. Then, of course, the folks who like to tinker might also be curious.
Let’s get this out of the way first…
The .deb file extension is also a format of the files. These files are software packages, handled by dpkg I suppose, and valuable only for those systems that are based on Debian (though I’m sure there’s an exception out there, it won’t be with a popular distro).
You see and use these files quite often if you’re using a distro based on Debian. Some examples of distros derived from Debian would be Ubuntu (and the Ubuntu family of official flavors), Linux Mint, elementaryOS, and a whole lot more. If you’re using ‘apt’ or ‘dpkg’ in the terminal, you’re almost certainly using a Debian derivative.
This means that this article isn’t appropriate for everyone. If you’re using a distro with a different package manager, this article won’t apply to you. Should you want me to cover that distro and think it’d make a good article, you can contact me. If you’re unfamiliar with Debian and its derivatives, you can read this Wikipedia page about the .deb file format.
The tool we’ll use to extract files from .deb files is known as ‘ar’ and should be installed by default. Any distro using .deb files, unless it’s a very stripped-down version, will contain the ar application. If you check the man page (
man ar), the naming section should indicate that it’s a suitable application for this task. More specifically, it says:
ar – create, modify, and extract from archives
If you check the actual description on the man page, it says this:
The GNU ar program creates, modifies, and extracts from archives. An archive is a single file holding a collection of other files in a structure that makes it possible to retrieve the original individual files (called members of the archive).
So, we have the right tool for the job. It’s a pretty useful tool that doesn’t get used all that much. The chance to introduce it to some new people is quite a privilege and I appreciate all of you who read this blog.
By the way, it has come to my attention (thanks to WizardFromOz from Linux.org’s forums) that you’ll not have ar installed by default. You’ll need to install it. Seeing as we know you’re using this package manager, you can install it by installing binutils. The command to do so is:
sudo apt -y install binutils
Speaking of this blog, I’ve been getting a great deal of ‘blog comment spam’. Automated attempts are pretty well locked down and prevented, so this means that people are doing this manually. They’re possibly even solving reCAPTCHA to do this and this is entirely a waste of time. It takes me mere seconds to deny the comments and the comments are never published.
I only publish comments that are acceptable (and I’ve even published some derogatory comments, just because I didn’t want to censor someone’s opinion – but I will censor spam). So, they’re not getting any return on their time and labor. Removing them annoys me. I get so few comments that I could almost justify disabling them entirely, but I want folks to be able to discuss any of my articles – and to correct me when I’m wrong or when I omit something important.
Anyhow, enough of that… Let’s just get into the article itself…
Extract Files From .deb Files:
Yes, we’ll be using the terminal. If you do not want to use the terminal, this is quite easy to do in the GUI. Simply open up your file manager, navigate to where you’ve stored the .deb file, right-click on the file, and choose to extract the files. You can also choose to open the file with your GUI archive manager and then extract just the files you want to extract. It’s pretty simple!
Now, for those of us who want to do this in the terminal, just press
With your terminal now open, navigate to where you’ve downloaded a .deb file. If you do not have a .deb to play with, you can do this:
With your existing .deb file, or with your freshly downloaded .deb file, we can now extract files from .deb files. The command would look similar to this:
ar x <file_name>.deb
If you use the
v flag (notice the lack of the
- part of the flag) then it’ll be verbose – meaning it will tell you the output. If you don’t need the output, you can skip it, just know that each .deb file should contain three files and that these three files should all be consistently named.
Should we put this all together, your command would look something like this:
ar xv google-chrome-stable_current_amd64.deb
Or, if it’s in a folder of its own, without any other .deb files, you can cheat and just use a wildcard – like this:
ar xv *.deb
The output of that command would look something like this:
~/Downloads/foo$ ar xv *.deb
x - debian-binary
x - control.tar.xz
x - data.tar.xz
And, if you navigate to the directory with your GUI file manager, you should see something that looks quite similar to this:
This should be consistent across all the various .deb files you extract. They’ll contain those two additional compressed files and a ‘debian-binary’ file. If you’re interested in what’s inside those ‘tar.xz’ files, you’ll have to use a search engine or wait for another article, because that’s more than I am going to get into.
I may still write a full article, but the way to extract those ‘tar.xz’ files is to do it like this:
tar -xf <file_name>.tar.xz
I trust you can figure it out from there. It’s a bit different from how you extract files from a .tar.gz file. So, it should maybe get an article all its own. This tiny bit of information won’t get indexed properly, so a whole article will make it easier to find and follow.
Well, this appears to be another long article. It doesn’t take all that much more time to write articles of this length. I’m kind of doing this as an experiment. I am interested in seeing how Google reacts to these longer articles, with more information and with more code and pictures as examples. I’m being optimistic because I don’t mind making the articles longer.
I have a ‘secret weapon’ I’ve been using since January of this year. That makes it much easier. I plan on doing an article about said secret weapon at some point, but I need to get my ducks in a row first. I hope it’ll be interesting and I’ll likely publish it on a day off so that it doesn’t stop the flow of regular articles. (The spice must flow!)
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.