Skip to content

~/avetyan.com/cheatsheets

Cheat sheets

apt vs dnf cheat sheet

The same package tasks side by side on Debian/Ubuntu (apt, dpkg) and RHEL, Rocky and Fedora (dnf, rpm): install, search, hold, history and repos.

5 min read


Everyday

TaskDebian / UbuntuRHEL / Rocky / Fedora

Update one-liners

Three levels, from most to least change. Run them as root or with sudo in front of each command.

GoalDebian / UbuntuRHEL / Rocky / Fedora
bash
# Debian / Ubuntu: full update, removes packages that are no longer needed
sudo apt update && sudo apt full-upgrade -y && sudo apt autopurge -y

# safe: upgrades and installs new dependencies, never removes anything
sudo apt update && sudo apt upgrade -y

# safest: only what unattended-upgrades is configured for (security, by default)
sudo apt update && sudo unattended-upgrade --dry-run -v   # see what it would do
sudo apt update && sudo unattended-upgrade -v

# RHEL family
sudo dnf upgrade --refresh -y && sudo dnf autoremove -y
sudo dnf upgrade --refresh -y
sudo dnf updateinfo list --security     # what security fixes are pending
sudo dnf upgrade-minimal --security --refresh -y
CommandInstalls new packagesRemoves packagesUpgrades

unattended-upgrade comes from the unattended-upgrades package; its origins are set in /etc/apt/apt.conf.d/50unattended-upgrades, and by default it only allows security updates (plus ESM on Ubuntu Pro). dnf --security needs advisory metadata in the repositories: RHEL, Rocky, Alma and Fedora updates publish it; CentOS Stream and many third-party repos don’t, so there it finds nothing.

Find packages

TaskDebian / UbuntuRHEL / Rocky / Fedora

Versions

TaskDebian / UbuntuRHEL / Rocky / Fedora

History

TaskDebian / UbuntuRHEL / Rocky / Fedora

Repositories

TaskDebian / UbuntuRHEL / Rocky / Fedora

Verify and clean

TaskDebian / UbuntuRHEL / Rocky / Fedora

dnf4 and dnf5

Fedora 41 and newer use dnf5; RHEL, Rocky and Alma 8 and 9 use dnf4. The commands in this sheet work on both, with these differences:

Commanddnf4 (RHEL family)dnf5 (Fedora 41+)

Keep in mind

  • In scripts, use apt-get and apt-cache: plain apt warns that its output may change. dnf is fine in scripts.
  • apt upgrade never removes packages; full-upgrade and autopurge may. Read the list before you answer yes, or drop -y the first time on a server.
  • After a kernel or libc update, check whether a reboot is needed (see the table above) before you call the update done.
  • On RHEL 9 and Fedora, yum is an alias for dnf.

Comments

Sign in with Google, GitHub or Facebook to comment.

Loading comments…