apt vs yum vs dnf: Which Linux Package Manager Should You Use?

If you've used multiple Linux distributions, you've run into this: Ubuntu uses apt, CentOS and RHEL use yum, and Fedora uses dnf. They all install software, but they're different tools with different syntax, different ecosystems, and different strengths.
This post explains when to use each one, how the syntax compares, and which you'll encounter most.
The Quick Answer
| Package Manager | Used By | Format |
|---|---|---|
| apt | Ubuntu, Debian, Linux Mint, Raspberry Pi OS | .deb |
| yum | RHEL 7, CentOS 7, Amazon Linux 2 | .rpm |
| dnf | Fedora, RHEL 8+, CentOS Stream 8+ | .rpm |
- You're on Ubuntu or Debian? Use
apt. - You're on Fedora or RHEL 8+? Use
dnf. - You're on an older RHEL 7 / CentOS 7 system? Use
yum.
If you're using a current server distro, you'll almost certainly encounter either apt or dnf. yum is increasingly legacy.
Side-by-Side Command Comparison
Install a package
# apt
sudo apt install nginx
# yum
sudo yum install nginx
# dnf
sudo dnf install nginx
Update package lists / check for updates
# apt (two separate steps)
sudo apt update # refresh package index
sudo apt upgrade # install available upgrades
# yum (combined)
sudo yum update
# dnf (same as yum syntax)
sudo dnf update
# or
sudo dnf upgrade # dnf treats update and upgrade as aliases
Remove a package
# apt
sudo apt remove nginx # keep config files
sudo apt purge nginx # remove config files too
sudo apt autoremove # remove unused dependencies
# yum
sudo yum remove nginx
# dnf
sudo dnf remove nginx
sudo dnf autoremove # remove unused dependencies
Search for a package
# apt
apt search keyword
apt-cache search keyword # older form, still works
# yum
yum search keyword
# dnf
dnf search keyword
Show package info
# apt
apt show nginx
apt-cache show nginx
# yum
yum info nginx
# dnf
dnf info nginx
List installed packages
# apt
apt list --installed
dpkg -l # alternative
# yum
yum list installed
# dnf
dnf list installed
rpm -qa # list all installed RPMs
Clean up cached files
# apt
sudo apt clean # clear downloaded package files
sudo apt autoclean # clear only outdated files
# yum
sudo yum clean all
# dnf
sudo dnf clean all
Key Differences
Package formats
- apt works with
.debfiles (Debian package format) - yum and dnf both work with
.rpmfiles (Red Hat Package format)
You cannot install a .deb on a Fedora system or an .rpm on Ubuntu with these tools. The package formats are fundamentally different.
dnf vs yum: What Changed?
dnf was designed as the successor to yum. The main improvements:
| Feature | yum | dnf |
|---|---|---|
| Dependency resolution | Slower, sometimes incomplete | Faster, more reliable |
| API | Legacy Python 2 code | Clean Python 3 API |
| Plugin compatibility | Older plugin ecosystem | Modern, maintained plugins |
| Memory usage | Higher | Lower |
| Parallel downloads | No | Yes (default) |
On RHEL 8+ and CentOS Stream 8+, yum is actually an alias for dnf — they're the same binary. If you type yum install, it runs dnf install underneath.
apt update vs apt upgrade: Why Two Commands?
This trips up everyone coming from yum or dnf.
sudo apt update # refreshes the package INDEX (what's available)
sudo apt upgrade # installs available UPGRADES
apt update does not install anything — it only downloads updated lists of available packages. You must run it before apt upgrade, otherwise you're upgrading based on stale information.
yum update and dnf update combine both steps in one command.
Holding packages at a specific version
Sometimes you don't want a package to update (e.g., a specific kernel version or database):
# apt — mark a package as held
sudo apt-mark hold nginx
sudo apt-mark unhold nginx
# yum/dnf — use versionlock plugin
sudo dnf install dnf-plugin-versionlock
sudo dnf versionlock add nginx
sudo dnf versionlock delete nginx
Repositories: Where Packages Come From
Both ecosystems rely on repositories — servers that host packages.
apt repositories
Ubuntu uses official repositories plus optional PPAs (Personal Package Archives):
# Add a PPA
sudo add-apt-repository ppa:user/ppa-name
sudo apt update
sudo apt install package-name
# Remove a PPA
sudo add-apt-repository --remove ppa:user/ppa-name
# List configured repos
cat /etc/apt/sources.list
ls /etc/apt/sources.list.d/
yum/dnf repositories
RHEL-based systems use .repo files:
# Enable EPEL (Extra Packages for Enterprise Linux)
sudo dnf install epel-release
# Add a custom repo
sudo dnf config-manager --add-repo https://repo.example.com/el/repo.repo
# List enabled repos
dnf repolist
EPEL provides thousands of packages not in the default RHEL/CentOS repos — it's the rough equivalent of Ubuntu's universe repository.
Installing from a File
Sometimes a vendor provides a .deb or .rpm file directly (e.g., Chrome, Slack, VS Code):
# apt — install a .deb file
sudo apt install ./package.deb # preferred: apt handles dependencies
sudo dpkg -i package.deb # older method, may leave broken deps
# dnf — install an .rpm file
sudo dnf install ./package.rpm # preferred
sudo rpm -i package.rpm # older method
# yum — install an .rpm file
sudo yum localinstall ./package.rpm
Using apt install ./ or dnf install ./ instead of dpkg or rpm -i means the package manager also resolves dependencies from the configured repositories.
Which Should You Learn First?
Learn apt first if:
- You're new to Linux and using Ubuntu (most common beginner distro)
- You're doing web development (Ubuntu is dominant in tutorials and cloud)
- Your team or course uses Ubuntu/Debian
Learn dnf second if:
- You work in enterprise environments (RHEL is common in large orgs)
- You're working toward RHEL certifications (RHCSA, RHCE)
- You use Fedora as a desktop
The syntax is similar enough that switching between them is straightforward once you know one. The main adjustment is remembering that apt needs two steps to update.
Quick Reference Card
| Task | apt | dnf | yum |
|---|---|---|---|
| Install | apt install pkg |
dnf install pkg |
yum install pkg |
| Remove | apt remove pkg |
dnf remove pkg |
yum remove pkg |
| Update index | apt update |
(included in upgrade) | (included in update) |
| Upgrade all | apt upgrade |
dnf upgrade |
yum update |
| Search | apt search kw |
dnf search kw |
yum search kw |
| Info | apt show pkg |
dnf info pkg |
yum info pkg |
| List installed | apt list --installed |
dnf list installed |
yum list installed |
| Clean cache | apt clean |
dnf clean all |
yum clean all |
| Auto-remove | apt autoremove |
dnf autoremove |
— |
Full Package Management Guide
For a deeper dive including managing services with systemctl after package installation, working with package groups, and dealing with dependency conflicts, see the Linux Package Management Guide.
Get The Practical Linux Handbook
Read a free sample
All Linux topics
Enjoyed this article? Share it!
About the Author
Vajo Lukic
Vajo Lukic is a technology leader with 20+ years of experience in software development and system administration. Author of The Practical Linux Handbook, he shares practical, field-tested knowledge to help developers and IT professionals master Linux fundamentals.
Read more about VajoRelated Articles

Linux File Permissions: The Complete Beginner's Guide (chmod, chown, umask)
Learn Linux file permissions from scratch. Understand rwx, chmod numbers, chown, and umask with clear examples that make the permission system click.
Read more →
Linux Process Management: A Complete Guide to ps, top, kill, and htop
Learn to list, monitor, and control Linux processes with ps, top, htop, and kill. Fix runaway processes, manage background jobs, and understand process states.
Read more →
Linux Shell Scripting for Beginners: From Zero to Your First Script
Learn Linux shell scripting from scratch. Variables, conditionals, loops, and functions explained with practical examples you can use immediately.
Read more →Ready to Transform Your Life?
Get the complete guide to personal transformation and start your journey today.
Get the Book