Home / Linux / How to Update CentOS/RHEL/Rocky/AlmaLinux with yum/dnf

How to Update CentOS/RHEL/Rocky/AlmaLinux with yum/dnf

Step-by-step updates for RHEL-based servers using dnf or yum, including command explanations, expected output, warnings, and final verification.

Views: 19 Unique: 17 Updated: 2026-03-20

What this is

This guide explains how to update RHEL-based Linux distributions (CentOS, Rocky Linux, AlmaLinux, RHEL) using dnf or yum.

What it is for

  • Apply security updates and bug fixes
  • Keep the VPS stable and supported

Prerequisites

  • SSH access
  • Root or sudo privileges
  • Recommended: snapshot/backup

Step-by-step

Step 1) Confirm your distribution

cat /etc/os-release

Expected output: Rocky/Alma/RHEL/CentOS info.

Step 2) Update packages (DNF)

sudo dnf update -y

What it does: Refreshes metadata and updates all installed packages.

Expected output: Transaction summary and package installation output.

Step 3) If your system uses YUM (older CentOS)

sudo yum update -y

What it does: Same goal as DNF (update packages) on older systems.

Step 4) Clean cache (optional)

sudo dnf clean all

What it does: Removes cached metadata/packages.

Why it is useful: Frees disk space and can fix metadata issues.

Step 5) Check if a reboot is recommended

Option A (if available):

sudo needs-restarting -r

Expected output: It may say a reboot is required or return a code.

Note: If the command is not found, skip to Step 6.

Step 6) Reboot (when required)

sudo reboot

Final verification

uptime
systemctl --failed

Expected output: Server is up and no failed services.

Conclusion

You updated your RHEL-based VPS safely. Make updates part of your routine maintenance.

Back to category