APT vs. DNF vs. YUM: Linux Package Managers Compared
Using the command line to add or remove programs on Linux isn’t necessary, but it is faster than using a graphical application. Many people find that at some point in their Linux journey, they end up opening a terminal to install new apps or system updates.
APT and DNF are two of the most popular package managers for the job. These two programs are very similar, but they do have some differences in how they function. Let’s dive in.
Getting to Know APT and DNF
APT and DNF have much in common and share similar syntax for many functions. If you are already familiar with either one, you probably won’t have a difficult time learning the other. If you’re a complete newcomer, know that these two package managers are among the easier ones to learn, especially compared to the less intuitive Pacman package manager found in Arch Linux and other Arch-based distros.
APT is short for Advanced Package Tool. It serves as the default package manager for Debian and, by extension, Debian-based Linux distributions like Ubuntu. Since Ubuntu is the most popular Linux distro, and there are scores of distros based on Ubuntu, APT is the package manager many of us encounter first. Software in Linux comes in different formats, and APT works with the DEB package format in particular.
DNF is the default package manager in Fedora and Fedora-based distros such as Red Hat Enterprise Linux and CentOS. DNF works with the RPM package format.
DNF vs. YUM
DNF’s name isn’t an acronym. Those three letters are short for “Dandified YUM.”
DNF is a rewrite of YUM, the “Yellowdog Updater, Modified.” YUM itself was already a rewrite of “Yellowdog UPdater,” or YUP, originally developed for Yellow Dog Linux.
While you may see YUM in use on older systems, it has been discontinued in favor of DNF. There isn’t much reason to seek out YUM today.
Example APT and DNF Commands
Let’s start with one of the first tasks many of us perform after installing a new Linux distro—downloading system updates.
Download System Updates
In APT, this consists of two commands.
sudo apt update
sudo apt upgrade
Let’s break these down.
sudo gives you administrative access to your system. Without it, your command will fail with an error message due to a lack of permission.
The update command downloads metadata about the packages from your available software sources so that your computer knows what versions to request.
Once your local database is up-to-date, then it’s time to download and install the latest software. That’s where the upgrade command comes in.
To install system updates using DNF, run:
sudo dnf update
sudo dnf upgrade
DNF checks for metadata automatically whenever you begin a system update or otherwise install software. For this reason, the update and upgrade commands perform the same function, and you are free to use them interchangeably.
Search for a Package
Let’s say you want to install a program, but you don’t know the exact name your distro uses for the package the program comes in. In a graphical app, you can browse through available software, but in the command line, you must perform a text-based search instead.
In this case, whether you’re using APT or DNF, you only need to remember a single command, and it’s one you could probably guess. If you want to search for a program with the name “package,” simply type:
sudo apt search package
sudo dnf search package
Like with performing a search, the command to install a program using APT or DNF is the same.
sudo apt install package
sudo dnf install package
One advantage DNF has over APT is the ability to install RPMs that you’ve downloaded manually from the web. You can do so using the same install command, but include the full path to the RPM instead of a package name.
sudo dnf install /path/to/package.rpm
In contrast, to install a DEB that you’ve put in your Downloads folder, you cannot use APT and must turn to a separate command-line program such as dpkg.
There are several ways to make software go away using APT. The first and most direct option is:
sudo apt remove package
To remove configuration files, in addition to app data, run:
sudo apt purge package
To have APT automatically remove software that was installed as a dependency and is no longer needed, you can use:
sudo apt autoremove
DNF doesn’t have a direct equivalent to the purge command, since RPM-based distros don’t manage configuration files in the same way as Debian-based systems. But the other two options are the same.
To uninstall a program using DNF, run:
sudo dnf remove package
And to automatically remove unneeded dependencies, use:
sudo dnf autoremove
DNF and APT Are More Alike Than Different
Some long-time Linux users have an established preference between APT and DNF. They’ve learned the syntax to do more powerful operations, and switching involves relearning what they already know.
But for newcomers, these two package managers are largely the same. Their differences are subtle, such as DNF automatically downloading package information before installing software or checking for updates.
The two package managers also present information differently, as you can see in the two screenshots above.
Yet both are command-line programs that operate near instantaneously, with wait times having more to do with your internet connection and the speed of the servers you’re connecting to. For most of us, gaining access to a different package manager is hardly a reason to switch from one Linux distro to another.
APT vs. DNF: Which Should You Use?
Whether you use APT or DNF largely depends on which distro you use. This means, for most Linux users, the choice is made for us. But if you do have a strong enough preference, you can choose your distro based on whether it uses APT or DNF.
Neither package manager is particularly more powerful or more capable than the other. So whichever one you’re stuck with is a perfectly fine one to learn. And if you do need to switch someday, doing so isn’t all that difficult.