Install A .deb Package In The Terminal

Today’s article is a basic article where we discuss how you can install a .deb package in the terminal. It isn’t all that complicated and there is almost always more than one way to accomplish things, especially when it comes to the terminal. If you want to install a .deb package in the terminal, this article is for you.

Obviously, this article only applies to distros that use the aptitude package manager, or ‘apt’ for short. These are generally the Debian-based distros. You’ll find that apt is used in Debian, Ubuntu, Linux Mint, ElementaryOS, and many more. It’s a pretty common theme among the more commonly mentioned desktop distros.

If you type man apt into the terminal, we get the following:

apt – command-line interface

That’s not very helpful, but it does give us some clues. It’s a command-line interface (often called “CLI”) for the package management system. If we read the man page a little further, it goes into more detail.

apt provides a high-level commandline interface for the package management system. It is intended as an end user interface and enables some options better suited for interactive usage by default compared to more specialized APT tools like apt-get(8) and apt-cache(8).

See? That’s a bit more helpful. When you’re reading the man page for an application, it’s a good idea to read the description portion of the man page. It explains a great deal, more often than not.

We will also be using ‘dpkg’ in this article. The man page (accessed with man dpkg) describes it accurately enough:

dpkg – package manager for Debian

Where apt is a “high-level” application, the ‘dpkg’ application is considered a “medium-level” application. The ‘dpkg’ application may be used by a higher-level application, providing a more stable command set and being used behind the scenes.

As a previous article about installing .deb files didn’t mention it, I figured it’d be worth an article of its own. I’ll still include installing software with apt, just so the folks arriving by search engine needn’t view multiple articles.

If you don’t already know, “.deb” files are packages for installing software. They adhere to the standard and are standard ar formatted archives. They’re meant to be used for installing software on your system, especially when you don’t have that software in your repositories. They often contain changes to system configurations and do the aforementioned software installations, so you need elevated permissions to run them.

If you’re curious about what’s inside, I wrote an article about that.

Extract Files From .DEB Files

For most users, they’re not all that interesting on the inside. You can extract them (even graphically) to see what’s on the inside. You can also use the extracted files if you can find a use for them.

So, today we’re going to learn how to extract a deb package from the terminal. We’ll cover a couple of different ways. If you want to do this graphically, you can do that. I’ve written another article about installing .deb files (not quite like this one) and the second section covers doing this graphically.

How To: Install .DEB Files In Ubuntu

With all that said, and hopefully understood, let’s get to it!

Install A .deb Package In The Terminal:

As the title implies, this is installing .deb packages in the terminal. To do this, you’ll need an open terminal. If you don’t know how to open a terminal, you may wish to learn. A terminal is a handy tool and you can usually open it by pressing CTRL + ALT + T.

With your terminal open, the absolute easiest way to install a .deb package in the terminal is to use that apt command mentioned earlier. It’s very simple:

Frankly, that’s probably the best choice. Using the higher level apt means that any dependencies will be sorted – if they can be sorted. If they’re not able to be sorted by downloading them from the default repositories, the application will fail gracefully and throw an error message. At that point, you can try to resolve the dependencies on your own, but that can be a pain in the butt.

Note the use of a full path. If you use apt, you must supply a path – something like ./foo.deb, ~/Downloads/foo.deb, or even /home/Downloads/foo.deb. Without a path, apt will not find the .deb file.

Anyhow, you can also install a .deb package in the terminal with the dpkg tool. It’s possibly a bit more complicated, but the syntax is as follows:

This is often adequate, but not always. The limitation is that the dpgk command doesn’t automatically resolve dependencies. It is because of this that I seldom recommend using dpkg and prefer to suggest using apt.

Never fear, this is still not lost. You can trivially resolve the dependencies (if they can trivially be resolved) with the following command:

That command will go through your installed software and try to fix (-f) any missing dependencies. If there are no dependencies needed, you do not have to run this command after installing packages with dpkg. 

Though, as you can see, it still relies on using apt. My thinking is that you can save all that hassle by just using apt in the first place. But, it’s your system. You have options when you want to install a .deb file in the terminal. It’s worth the article just to let folks know.

Some folks still recommend installing with dpkg and then running the apt command to resolve dependencies. I do not know why. If you have any good ideas about why, do feel free to let me know in a comment.

Closure:

Well, there you have it. You have yet another article, and yes it’s another one that relies on using the terminal. There are GUI tools that happily take care of all of this for you.

There’s no need to use the terminal to install software, but I prefer it. It’s just as quick for me to type out a command as it is for me to open software, type my password, and then click a button or two. It’s probably faster for me, as I always have a terminal open.

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.

Extract Files From .DEB Files

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:

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 CTRL + ALT + T, and your default terminal should open. Not every distro has this keyboard shortcut as a default, and that’s just horrible. It really should be universal and your distro (should this shortcut not already work) will likely have a way to map those keys to open a terminal. 

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:

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:

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:

The output of that command would look something like this:

And, if you navigate to the directory with your GUI file manager, you should see something that looks quite similar to this:

the results if you extract the files from the Google Chrome .deb
Assuming the .deb follows standards, it’ll look just like that, regardless of the application.

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:

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. 

Closure:

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!)

As always…

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.

How To: Install .DEB Files In Ubuntu

Today’s article is only useful for a subset of my readers, that is those who need to know how to install .deb files in Ubuntu. That’s a bit cheeky of a headline, but there’s a character limit to adhere to. So, if you want to install .deb files in Ubuntu, this article is for you…

What are .deb files?

The .deb file extension means that it is a package meant to be installed in Debian. So, this article will be valid for all Debian users – even those downstream, like Ubuntu or Linux Mint.

Quite a few Linux distros use .deb files, not just Ubuntu. I happen to be an Ubuntu member and many of my readers use distros based on Ubuntu (which is, of course, based on Debian). To keep things short, we’re not going to type all that out over and over again.

Many new users start with Ubuntu or Mint, and Debian itself of course. You might be a new user and have reached the point where you’re comfortable installing software from the graphical installer built into your operating system of choice.

Well, this is Linux… There are all sorts of ways to do things! Assuming you’re safe, or unsafe if you want – it’s your choice, you can find software that’s not available in the graphical installer, or newer versions than what you’ll find in the graphical installer. You’ll often find this software available in .deb format and this article will show you a few ways to install those .deb files.

How To: Install .DEB files in Ubuntu:

The first way we’re going to cover will be in your terminal. You’ll likely need an open terminal for the rest of the methods, so you might as well open your terminal now. You can just smash the CTRL + ALT + T and your default terminal application should pop open.

The first method is pretty easy. You’re simply using ‘apt’ in the terminal, much like you’d do if you wanted to update from the terminal. The command would look something like this:

You’ll usually have downloaded the file to your Downloads directory, so you can either navigate to Downloads using the cd command or you can just include the folder in your path to the file, kind of like this:

Of course, you’ll use the actual file name and you’ll be asked for your password (unless you’ve changed that). Enter your password and let apt do its thing. Using apt is great because it will do its best to resolve any dependency issues you might have.

Now onto some GUI ways to install .deb files in Ubuntu!

Install .DEB Files With GDebi:

You followed the directions above and have an open terminal, right? Good, because GDebi doesn’t always come installed by default. I’ve previously written an article about GDebi, but it’s actually on the old site. I won’t bother linking it.

GDebi is a great GUI, that is a graphical, way to install .deb files. In fact, on the man page, it is described as:

gdebi – Simple tool to install deb files

To install .deb files with GDebi you first need to install it. You can do that right there in the terminal. To install GDebi, just run this command:

Once you have GDebi installed, you just use it from the right-click menu. Use your file manager to navigate to the download’s directory. Then you just right-click on the .deb file and choose to install it. The first time around, you might need to do some sort of ‘open with’ exercise, but then it should appear as something like “Open with GDebi package installer” or you will pick it from a list.

I’m positive you can figure it out from there. The great thing about using this GUI method to install software in Ubuntu is that it too will attempt to deal with any dependency issues automatically.

Install .DEB Files With QApt:

Do you still have that terminal open? Good! We have one final graphical method to install .deb files in Ubuntu. This one is a fairly new application and it’s a Qt application. However, it installs with very few dependencies and takes up very little space. Functionally, it’s very similar to GDebi.

So then, let’s start with getting QApt properly installed. The name is quite a bit longer, but it’s still easy to install QApt. To install the software, try this:

It’s a nice and light way to graphically install .deb files. For the life of me, I can’t figure out the correct man page incantation to make it work. No amount of trying the various words results in a man page opening. I do not know why, but I do know that it works. If you search to install QApt, it describes itself as:

qapt-deb-installer – tool for installing deb files

That’s plenty accurate. That’s what it is and that’s what it does. While I can’t find a man page for QApt, that’s an adequate description.

This QApt is a bit different. Like with GDebi, you’ll use your file manager to navigate to the directory that contains your .deb file (usually the Downloads directory) and right-click on the .deb file you wish to install. You’ll then pick “Open With” and click on the “QApt Package Installer”. With QApt now open, you’ll just click the obvious install button and wait patiently for it to do its thing.

Closure:

So, there you have it… You have another article and this one has you learning how to install .deb files in Ubuntu. There are a few ways and you can pick the one that works best for you. Much of the time, I already have a terminal open and already navigated to the ~/Downloads directory. Because of this, I’ll often just do the installation right there in the terminal, using the apt command. But, it’s up to you. You have choices!

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.

Use an RPM on a DEB-based System

Once in a while, you’ll come across a piece software that’s only in RPM format. It’s possible to convert RPM to DEB and you may be able to install that software on your DEB-based system.

You’ll find that it’s not unusual to come across software packaged in a format that you can’t use. That’s just the name of the game. Developers and package maintainers are going to concentrate on the stuff they themselves use. It’s not selfishness that prevents them from packaging it in different formats, it’s just a matter of time and priorities. 

It’s times like these when you can use a nifty little tool called ‘alien‘. Alien has been around for a long time and is really useful. It can actually be used in both directions, converting between .deb and .rpm interchangeably. 

Convert With ‘alien’

So, let’s get started. This won’t take very long and will be a valuable tool for your tool-chest. If you don’t need it today, put it aside for a future date. As you progress along your Learning Linux Journey, it may well prove valuable.

As you know, the tool we’ll be using is ‘alien’ and the man-page defines it as this:

alien – Convert or install an alien binary package

You’ll install it with your package manager. As we’re using an apt-based system, we’ll be using apt to install the software. Crack open your terminal with CTRL + ALT + T and enter the following:

That’s going to pull in quite a few dependencies. On a stock Lubuntu installation, it pulls in about 200 MB worth dependencies, so you should be aware of this.

Now that you have it installed, there are a couple of ways you are most likely to use it. The first, given that we’re talking about Debian/Ubuntu/derivatives, would be converting an .rpm to a .deb. That’s pretty easy. Just do this:

That will convert the package to .deb and you can install it in the normal ways. Seeing as you’re right there in the terminal already, you can just use:

You can skip all that and do the conversion and installation all at the same time. To do this, you simply use the -i switch. It looks like this:

NOTE: This won’t always work. The package you converted may not work, usually due to dependencies that can’t be satisfied. If it doesn’t work, you’ll have to look for other solutions.

If you want to go the other direction, you can use this:

There are other ways to use alien, but those are the most common ways that I see it being used – and the ways I’ve historically used it. It has been effective most of the times I’ve tried it, but I am just a single data point and anecdotes aren’t really data.

If you’re interested in other uses (such as tgz or slp), you can consult the man-page or read the online man page. It’s a fairly versatile application and one that all Linux users should know about.

Once again, thanks for reading. Don’t forget that there’s a newsletter and that you can now donate to help cover any hosting costs. If you want to contribute, there are all sorts of ways that you can help – just let me know.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.