What is the difference between APT and dpkg in Ubuntu?

Ubuntu and other Debian-based distributions manage packages using APT and dpkg. But which one is best suited to your needs?

Cardboard boxes printed with the words apt and dpkg

If you are using Ubuntu or any other Debian based Linux distribution, you have undoubtedly read the installation instructions asking you to use the APT command, while others have told you to use dpkg.

So, is it important that you install packages on your Linux system with one of these package managers? What is the difference? Today we will cover these questions so that you know how to best install packages on Ubuntu.

APT vs dpkg: two important package installers

Installing the Discord Deb file with Apt

APT and dpkg are both command line package management interfaces that you can use in the terminal on Ubuntu and other Debian based systems. Among other things, they can install DEB files and list installed packages.

But you might be wondering if they are so similar, why do you need both APT and dpkg?

The two interfaces actually work together, with APT acting as a complete package management tool through the use of dpkg.

Confuses? Let’s break down the main differences.

APT uses dpkg to install packages

When APT (or its cousin, Apt-get) installs a package, it actually uses dpkg on the back-end to accomplish this. In this way, dpkg acts more as an “under the hood” tool for APT’s more user-friendly interface.

APT can download packages

With APT, you can grab a file from a remote repository and install it, all with one command. This eliminates the need for you to manually find and download the package before installation.

With dpkg, you can only install local files that you have already downloaded yourself. It cannot find remote repositories or extract packages from them.

Dpkg does not install dependencies

When you install a package with dpkg, that’s all that happens – the system just installs the package. However, some packages require additional software called dependencies to function. If so, dpkg may warn you with an error message.

Installing the Discord Deb file with Dpkg

APT, however, will automatically check and obtain the relevant dependencies to ensure that whatever you are trying to install is working properly. Therefore, we recommend that after installing a package with dpkg, you use APT’s special command to restore dependencies.

sudo apt install -f

Dpkg only index local packages

If you are trying to discover the packages installed on your system, the –listing function in dpkg might serve you better than APT. This is because, just as it cannot find and download remote packages, dpkg also cannot list packages that are not local on the device.

dpkg --list

APT listing The command will list all the packages it is aware of, locally or otherwise.

apt list

To see only the installed packages, you must pass the –installed or -I option.

apt list --installed

Dpkg vs Apt: which one is better for you?

If you want to install local packages with dpkg, you can do so without encountering any issues. However, you are better off with APT or Apt-get if you regularly search for packages on remote software repositories.

APT will do the work of finding and downloading the desired package and ensure that all necessary dependencies are met. You can still use dpkg, but APT will perform the same function while ensuring that your software works as you need it to. Additionally, APT is great for properly uninstalling packages and removing them from your system.

uninstall packages with apt
How to uninstall software in Linux with Apt

Uninstalling the software ensures that you have enough space on your storage device. Here is how to uninstall applications in Linux with Apt.

Read more

About the Author


Source link

About Brian Steele

Brian Steele

Check Also

Canonical announces end of life date for Ubuntu 20.10 Groovy Gorilla

Canonical announced that Ubuntu 20.10 Groovy Gorilla is slated to lose support on July 22, …

Leave a Reply

Your email address will not be published. Required fields are marked *