How to let `dpkg -i` install dependencies for me?

Solution 1:

After using dpkg, running the following command helped me to install the required dependencies:

sudo apt-get -f install

In all, your terminal should look like this:

$ sudo dpkg -i package_with_unsatisfied_dependencies.deb
dpkg: dependency problems prevent ... 
[additional messages]

$ sudo apt-get -f install
[apt messages]
Setting up [dependency]...
Setting up package_with_unsatisfied_dependencies...

Notice the line about Setting up package_with_unsatisfied_dependencies. This fixes (and completes) the installation of package_with_unsatisfied_dependencies.deb.

Solution 2:

starting with apt 1.1 (available in Xenial (16.04), stretch) apt install also allows local files:

sudo apt install ./foo-1.2.3.deb

So much simpler and cleaner.

See the release announcment

Solution 3:

You can install gdebi-core, which is the command line version of the GDebi package installer from 10.04 and earlier. In the newer versions of Ubuntu, the Software Center is used to install debs, which doesn't have a command line equivalent.

To install a deb package using gdebi, just run:

sudo gdebi my_package_1.0.deb

Solution 4:

Gdebi

gdebi installs a deb package and its dependencies. To use it run:

sudo gdebi package.deb

In newer versions of Ubuntu, this is not installed by default, so you will need to install it from the repositories.

See man gdebi for a full list of options.

gdebi is the command line equivalent to the graphical tool of the same name that used to be included by default in Ubuntu. The command for the graphical tool is gdebi-gtk and has similar functionality:

gdebi-gtk