How to install local .deb files with its dependencies?

Jaime Lin
2 min readAug 30, 2021

These days I packed tons of Debian packages… and I found it’s quite difficult to remember those dpkg commands. Here to record them for me.

First of all, what’s dpkg?

dpkg is the software at the base of the package management system in the free operating system Debian and its numerous derivatives. dpkg is used to install, remove, and provide information about .deb packages. — https://en.wikipedia.org/wiki/Dpkg

For newbies, this provides lots of useful information.

$ dpkg --help

(1) Install a .deb file into the system by dpkg

$ dpkg -i example.deb

This provides .deb package information.

$ dpkg -I example.deb

This shows .deb package content.

$dpkg -I example.deb

Dpkg is a great tool to install packages, but it still has some drawbacks. One of them is that it can’t install package dependencies at the same time. So we need Solution 2.

(2) Install a .deb file by dpkg with dependencies

$ mv ./example.deb /var/cache/apt/archives/
$ apt install -f /var/cache/apt/archives/example.deb

Move the .deb files to /var/cache/apt/archives/ is needed. Otherwise, it can’t locate the package. Take an example:

$ apt install deb_dist/example.deb 
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package deb_dist

Well… It seems a bit of a bother. So herewith the Solution 3.

(3) Install a .deb file by gdebi

Let gdebi package does it for you.

$ apt install -y update
$ apt install -y gdebi
$ gdebi example.deb

If you like this post, you can thumb up or buy me a coffee! :)

--

--

Jaime Lin

From Taiwan, a beautiful island. Learning English and sharing code experience.