Since 2016 · 50,000+ customers · ★ 5.0 on Google Live chatWhatsAppTelegramOpen a ticket
Get started
Linux

How to Update and Upgrade Packages with apt, yum and dnf

How to update and upgrade packages with apt, yum and dnf by 99RDP

Keeping a Linux server updated is the single most important security habit, and every distribution family has its own package manager for it. Debian and Ubuntu use apt; Fedora, RHEL, AlmaLinux and Rocky Linux use dnf; old CentOS 7 systems use yum. The commands look similar but behave differently, and mixing them up (like running sudo apt update on Fedora) is one of the most common beginner errors. This guide gives the right commands for each, explains "update" vs "upgrade", and shows how to update a single package, clean up, check if a reboot is needed and automate it.

Quick answer

# Debian / Ubuntu
sudo apt update && sudo apt upgrade -y

# Fedora / RHEL / AlmaLinux / Rocky (8 and later)
sudo dnf upgrade -y

# CentOS 7
sudo yum update -y

Which package manager does my server use?

Run cat /etc/os-release. Ubuntu, Debian, Linux Mint and Kali use apt. Fedora, RHEL, AlmaLinux, Rocky Linux and CentOS Stream use dnf. CentOS 7 and Amazon Linux 2 use yum. On Fedora there's no apt, so sudo apt update fails with "command not found"; use sudo dnf upgrade instead.

sudo apt update && sudo apt upgrade on an Ubuntu server listing the packages to upgrade before confirming
Updating packages with apt
Table of which package manager each Linux distribution uses: apt, dnf or yum
Which one is yours

APT (Debian, Ubuntu and derivatives)

With apt, "update" and "upgrade" are two separate steps:

CommandWhat it does
sudo apt updateRefreshes the package lists from the repositories. Installs nothing.
sudo apt upgradeInstalls newer versions of installed packages; never removes packages.
sudo apt full-upgradeSame, but may add or remove packages to resolve dependencies (needed for some kernel and library changes).
sudo apt install --only-upgrade nginxUpgrade a single package.
apt list --upgradableShow what would be upgraded.
sudo apt autoremoveRemove dependencies that are no longer needed, including old kernels.
sudo apt cleanDelete downloaded package files to free space.

Upgrading to a new Ubuntu release (for example 24.04 to 26.04) is a different process: use sudo do-release-upgrade.

DNF (Fedora, RHEL 8+, AlmaLinux, Rocky Linux)

dnf refreshes metadata automatically, so one command does everything. dnf update and dnf upgrade are the same thing.

CommandWhat it does
dnf check-updateList available updates without installing.
sudo dnf upgradeUpgrade all packages.
sudo dnf upgrade nginxUpgrade one package.
sudo dnf upgrade --securityInstall only security updates (RHEL-family with update info).
sudo dnf autoremoveRemove unneeded dependencies.
sudo dnf clean allClear cached metadata and packages.
dnf history / sudo dnf history undo NSee past transactions and roll one back.

YUM (CentOS 7 and other older systems)

CommandWhat it does
yum check-updateList available updates.
sudo yum updateUpgrade all packages.
sudo yum update httpdUpgrade one package.
sudo yum upgradeLike update, but also removes obsolete packages.
sudo yum clean allClear the cache.

On RHEL 8 and later, yum still exists but is just an alias for dnf. CentOS 7 itself is end of life and its mirrors are offline, so plan a move to AlmaLinux or Rocky Linux.

Summary table

Taskaptdnfyum
Refresh package listsapt updateautomatic (dnf makecache)automatic
Upgrade everythingapt upgradednf upgradeyum update
Upgrade one packageapt install --only-upgrade pkgdnf upgrade pkgyum update pkg
Remove unused depsapt autoremovednf autoremoveyum autoremove
Clean cacheapt cleandnf clean allyum clean all

Do you need to reboot?

# Ubuntu/Debian
[ -f /var/run/reboot-required ] && cat /var/run/reboot-required

# RHEL family
sudo dnf needs-restarting -r

Kernel, glibc and systemd updates usually need a reboot to take effect. Plan it for a quiet time.

Reboot or restart after updates: kernel, glibc and systemd need a reboot, most others a service restart
Reboot or restart?

Automate security updates

  • Ubuntu/Debian: sudo apt install unattended-upgrades then sudo dpkg-reconfigure unattended-upgrades. Ubuntu enables it for security updates by default.
  • RHEL family: sudo dnf install dnf-automatic, set apply_updates = yes in /etc/dnf/automatic.conf, then sudo systemctl enable --now dnf-automatic.timer.

Frequently asked questions

What's the difference between apt update and apt upgrade?

apt update downloads the latest package lists; apt upgrade installs the newer versions. Run update first.

Is yum update the same as yum upgrade?

Almost. yum upgrade also removes obsolete packages. On dnf systems, update and upgrade are identical.

Why does "sudo apt update" not work on Fedora?

Fedora doesn't use apt. Use sudo dnf upgrade.

How often should I update a server?

Apply security updates at least weekly, or automatically, and test larger upgrades before running them on production.

Nishant Kumar, Sr. Server Engineer at 99RDP
Written byNishant KumarSr. Server Engineer, 99RDP. Part of the team that runs our servers and answers support.
Keep reading

More Linux guides

All Linux guides

Need a server for this?

✓ Setup in minutes✓ Full admin access✓ 7-day refund on new services