How to install a .deb from the terminal

I tend to use the terminal more than most people I think. When I was very new at Linux, I hated the terminal – I thought it was really dumb to have such an advanced operating system, like Linux, use something little more than a command line. I’ve since revised my view on that and I think it would absolutely stupid not to have one and I spend far more time in a Linux terminal than I do with the GUI.

What’s nice about the terminal is that it doesn’t change much, unlike the GUIs. Anyway, there are a few ways to install .deb packages from the terminal. One that will resolve dependencies and one that won’t.

Dependencies, in Linux, are other packages required by the package you are trying to install. Similarly, in Windows, if you were trying to install a game, a dependency might be DirectX, or if you have an app written in .net, you’d need the .net framework.

In any event, the first way (and probably the more common way) is dpkg. To do this in the terminal you simply cd to where the directory is that houses your .deb file and run this:

$ sudo dpkg -i yourpackage.deb

The only problem with dpkg is that it doesn’t offer any dependency resolution. So if your package fails to install because of dependency issues, you’ll have to run this:

$ sudo apt-get -f install

Which will resolve any unmet dependencies (if those dependencies are in your repositories) as well as install the package you were trying to install. For kernel packages and other other packages that require no dependencies, this is the way to go.

For packages that require dependencies, I tend to use gdebi. It’s basically the same syntax, except like this:

$ sudo gdebi yourpackage.deb

Fairly straight forward. If your dependencies are not in the repository, you’ll have to manually start finding the packages and installing them as they need to be installed and it’s basically going to be a chain of installs.