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.

Last Updated on August 9, 2023 by KGIII

Subscribe to Newsletter!
Get notified when new articles are published!
We promise to never share your email!
icon

Author: KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *

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.