>
Linux distributions rely on package managers to install, update, and remove software. The three most widely used are apt (Debian/Ubuntu), yum (RHEL/CentOS 7), and dnf (RHEL/CentOS 8+). Each has distinct syntax, performance characteristics, and use cases—and choosing the right one depends on your distribution.
A package manager is a tool that automates the process of installing, upgrading, configuring, and removing software packages on a system. Instead of compiling software from source or manually downloading binaries, you run a single command. The package manager handles dependencies, version compatibility, and file placement automatically.
This is what separates Linux from operating systems where you hunt for installers on the web. With a package manager, your entire software ecosystem stays consistent, traceable, and updatable from the command line.
APT (Advanced Packaging Tool) is the package manager for Debian-based distributions like Ubuntu, Linux Mint, and Pop!_OS. It's been refined over two decades and has become the gold standard for ease of use.
# Update package list
sudo apt update
# Upgrade all packages
sudo apt upgrade
# Install a package
sudo apt install nginx
# Remove a package (keeping config files)
sudo apt remove nginx
# Remove a package completely
sudo apt purge nginx
# Search for a package
apt search postgresql
# Show package information
apt show curl
# Fix broken dependencies
sudo apt --fix-broken install
# Clean up unused packages
sudo apt autoremove
APT's strength lies in its simplicity and interactive feedback. When you install something, it clearly shows what dependencies it'll pull in. The syntax is intuitive—most commands follow a predictable pattern. For beginners, this predictability is invaluable.
APT uses the dpkg package format (.deb files). When you run apt install nginx, APT queries its cache, downloads the package and its dependencies from configured repositories, verifies signatures, and installs everything in the correct order. You can configure multiple repositories in /etc/apt/sources.list, which is why you often see PPA (Personal Package Archive) commands on Ubuntu.
YUM (Yellowdog Updater, Modified) has been the default package manager for RedHat Enterprise Linux, CentOS, and Fedora for years. It handles RPM packages (.rpm files) and handles dependencies more intelligently than raw rpm commands, but with different syntax than APT.
# Update metadata
sudo yum check-update
# Install a package
sudo yum install httpd
# Remove a package
sudo yum remove httpd
# Update all packages
sudo yum update
# Search for a package
yum search nodejs
# Get package info
yum info mysql
# List installed packages
yum list installed
# Clean cache
sudo yum clean all
# Install from local file
sudo yum install /path/to/package.rpm
YUM's main weakness is speed—it can be noticeably slower than APT, especially during metadata operations. The dependency resolution algorithm is solid but doesn't provide the same real-time feedback. However, it's rock-solid for production environments where stability matters more than responsiveness.
DNF (Dandified YUM) is YUM's successor, introduced in Fedora 18 and becoming the default in RHEL 8 and CentOS 8. It's written in Python, uses the same RPM format, but fixes YUM's performance issues and provides cleaner output.
# Update metadata
sudo dnf check-update
# Install a package
sudo dnf install apache2
# Remove a package
sudo dnf remove apache2
# Update all packages
sudo dnf upgrade
# Search for a package
dnf search git
# Get package information
dnf info python3
# List installed packages
dnf list installed
# Enable a repository
sudo dnf config-manager --enable extras
# Clean cache
sudo dnf clean all
# Install from URL
sudo dnf install https://example.com/package.rpm
DNF is significantly faster than YUM and handles complex dependency scenarios better. Its output is cleaner and more user-friendly. If you're working with modern RHEL, CentOS, or Fedora systems, DNF should be your go-to choice.
| Feature | apt | yum | dnf |
|---|---|---|---|
| Distribution | Debian, Ubuntu, Mint | RHEL, CentOS 7 | RHEL 8+, CentOS 8+, Fedora |
| Package Format | .deb | .rpm | .rpm |
| Speed | Fast | Slow | Fast |
| Ease of Use | Excellent | Good | Excellent |
| Dependency Resolution | Excellent | Good | Excellent |
| Learning Curve | Shallow | Moderate | Shallow |
While all three managers do the same job, their command syntax differs. Here's how the same task looks across all three:
# Install a package
apt install vim # Debian/Ubuntu
yum install vim # RHEL/CentOS 7
dnf install vim # RHEL/CentOS 8+
# Update everything
apt upgrade # Debian/Ubuntu
yum update # RHEL/CentOS 7
dnf upgrade # RHEL/CentOS 8+
# Remove a package
apt remove vim # Debian/Ubuntu
yum remove vim # RHEL/CentOS 7
dnf remove vim # RHEL/CentOS 8+
# Search for a package
apt search vim # Debian/Ubuntu
yum search vim # RHEL/CentOS 7
dnf search vim # RHEL/CentOS 8+
Notice that apt and dnf use slightly more consistent naming conventions. The core commands are similar, but once you go beyond basics (like enabling repos or handling configurations), the differences become more pronounced.
Each manager handles repositories slightly differently. Repositories are remote servers that host packages. The manager queries these servers to find and download software.
APT (Ubuntu):
# Add a PPA
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11
# Or manually edit
sudo nano /etc/apt/sources.list
DNF (RHEL/CentOS 8+):
# Enable a built-in repository
sudo dnf config-manager --enable powertools
# Add an external repository
sudo dnf config-manager --add-repo https://example.com/repo.repo
sudo dnf repolist
YUM (RHEL/CentOS 7):
# Add EPEL repository
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum repolist
All three managers verify package signatures before installation. APT uses GPG keys stored in /etc/apt/trusted.gpg.d/. YUM and DNF use RPM signatures. This prevents man-in-the-middle attacks and ensures you're installing authentic software.
When you add a new repository, it's critical to verify its GPG key. Untrusted repositories can compromise your entire system. Always install packages from official sources or well-maintained third-party repos.
sudo apt --fix-broken install
sudo apt autoremove
sudo dnf install --allowerasing package-name
sudo dnf autoremove
# APT: Show what would break
sudo apt install package-name --no-act
# DNF: Allow replacing conflicting packages
sudo dnf install --allowerasing package-name
If you encounter "unmet dependencies," it usually means the repository doesn't have the required package version. Update your repository lists with apt update or dnf check-update, and verify you're pulling from the right repos.
APT is generally the fastest for basic operations. DNF matches it on modern systems. YUM can hang during metadata updates, especially on slower connections—this is a known limitation that drove development of DNF.
For systems managing thousands of packages, the difference is negligible. But on slower machines or constrained networks, apt or dnf will feel noticeably snappier.
All three managers support non-interactive mode for automation:
# APT (non-interactive)
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y package-name
# YUM (non-interactive)
sudo yum install -y package-name
# DNF (non-interactive)
sudo dnf install -y package-name