DEV Community

Serhat Teker
Serhat Teker

Posted on • Originally published at tech.serhatteker.com on

How to Install Deb Packages

.deb is the installation package format used by all Debian based distributions like Ubuntu, Kali , Linux Mint , Pop!_OS etc. and of course Debian itself.

In this post, I will explain how to install .deb files on Ubuntu. The same instructions apply for any other Debian based distribution as mentioned above.

The Ubuntu repositories contain thousands of deb packages that can be installed either from the Ubuntu Software Center or from the command line using the apt.

However many applications are not included in the Ubuntu or any 3rd party repositories. Another reason that you'd like to install a local deb package would be their version on default package manager could be old and you'd like to get new version of them.

Those unofficial applications can be downloaded from the developer’s websites or git repositories and installed manually. But be careful when installing .deb packages from unofficial sources especially if it's not open source.

Downloading Deb Package

For demonstration let's download Vscode IDE via wget:

$ wget -O 'vscode-stable.deb' 'https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64'
Enter fullscreen mode Exit fullscreen mode

As you may guess from query paramaters this command will download 64 bit architecture of Vscode deb package from official Vscode repository as named vscode-stable.deb in your current working directory.

Installing Deb Package

When it comes to installing deb packages there are command-line or graphical user interface options.

From the command line you have several tools at your disposal as well. In the following sections, I will show you how to use apt, and dpkg utilities to install deb packages.

dpkg

dpkg is a low-level package manager for Debian based systems. Use the -i or --install flag to install deb packages with dpkg.

# First update package indices
$ sudo apt update
# Install via dpkg
$ sudo dpkg -i ./vscode-stable.deb
Enter fullscreen mode Exit fullscreen mode

Unlike apt, dpkg doesn’t resolve dependencies. If you get any dependency errors when installing deb packages, you can use the following apt command to resolve and install all package dependencies:

$ sudo apt install -f
Enter fullscreen mode Exit fullscreen mode

apt

apt is a command-line utility for installing, updating, removing, in short managing deb packages on Ubuntu, Debian, and related Linux distributions. It was introduced in Ubuntu 14.04 and combines the most commonly used commands from apt-get and apt-cache.

The apt package manager will resolve and install all the package dependencies by itself, so it's better to use apt instead of dpkg.

To install local deb packages with apt you need to provide the full path to the deb file. If the file is located in your current working directory instead of typing the absolute path, you should prepend ./ before the package
name. Otherwise, apt will try to retrieve and install the package from Ubuntu’s repositories.

Let's assume you are in the same directory after wgetting Vscode deb package, then just simply run:

# First update package indices
$ sudo apt update
# Install via apt
$ sudo apt install ./vscode-stable.deb
Enter fullscreen mode Exit fullscreen mode

Conclusion

We saw how to install local deb packages on a Debian based distribution —as an example Ubuntu. When installing deb packages prefer using apt since it resolves and install all the package dependencies.

All done!

Top comments (0)