Apt vs Dpkg – Comparing The Two Debian Package Managers

APT Vs Dpkg

In this article, we’ll compare apt vs dpkg package managers. If you use Ubuntu (or Mint, Debian, etc), you are already familiar with apt. It is used for installing, finding, removing packages, etc. But you might have also seen tutorials using dpkg to install packages.

So does it really matter which software you use to manage your packages? Let’s look at the differences and use cases of these two package managers.

What is APT?

APT stands for Advanced Packaging Tools used in Debian and its derivatives to manage packages. It is used for installing, upgrading, configuring, removing packages, and maintaining source repositories. But, Linux has a modular design philosophy which APT also follows.

Instead of doing all tasks themselves in a monolithic manner, it employs several different applications under the hood to do those tasks. For example, it might use curl to download the .deb source package and all its dependencies and then use dpkg to install it.

What is dpkg?

dpkg (Debian Package Manager) works under the hood of APT. While APT manages remote repositories and resolves dependencies for you, it uses dpkg to actually make the changes of installing/removing packages. dpkg on itself cannot retrieve/download files from remote repositories, nor can it figure out dependencies.

Users can use dpkg on its own to install local .deb packages using dpkg -i

Dpkg Install

Other independent uses of dpkg :

  • dpkg –unpack can be used to unpack a package to make any changes to it.
  • dpkg –configure is used on a package that is already unpacked but not yet configured.
  • dpkg –compare-versions compares two versions of a package and if the comparison is true, it returns a 0 indicating success. The comparison operators are <, <<, <=, =, >=, >>, >.
  • dpkg –add-architecture can be used to add architectures for which the package is compatible for.

Tip: If you use dpkg -i to install a package and it runs into dependency errors, run sudo apt-get install -f first to resolve dependency errors and then run dpkg -i again.

Comparing apt vs dpkg – Quick summary

We cant differentiate between the two applications properly because they are supposed to work on different levels and have separate functionality. However, this gives a decent idea of what the applications are capable of doing and what they are not.

FunctionsAPT dpkg
Can download packages from remote repositories YESNO
Can resolve dependencies YES NO
Install local packages YES (using dpkg)YES
Install remote package YES (using dpkg)NO (users need to manually download a package if they wish to use dpkg)
List installed packagesYESYES

Should we ever use dpkg?

dpkg is a low-level application usually not supposed to be used by the end-user. Using dpkg over APT would mean, manually downloading the package, manually figuring out and downloading all dependencies, manually downloading any upgrades, etc. Users can however use it to install .deb packages that aren’t available on remote repositories such as Discord and Steam.

Most of what dpkg does can be done directly through apt as shown below.

  • To install a local package we can use apt install ./<path/to/package.deb> instead of dpkg -i <path/to/package.deb>
  • To list packages, we can use apt list instead of dpkg -l

That said, dpkg does have exclusive uses such as configuring/ unpacking/ repacking and comparing packages as discussed above.

Conclusion

dpkg and APT are not made to do the same things. APT instead utilizes dpkg under the hood to install packages. dpkg can however be used to install and list locally installed packages. To read more about dpkg and apt refer to Debian wiki. Thank you!