How to Update AlmaLinux 9, Rocky Linux 9, Ubuntu 26.04 and Debian 13
Apply system updates on the RHEL 9 family, Ubuntu 26.04 LTS and Debian 13 with dnf and apt, check whether a reboot is pending and enable automatic updates.
This guide shows how to install pending updates on the three server families you are most likely to run today: the RHEL 9 family (AlmaLinux 9, Rocky Linux 9, CentOS Stream 9), Ubuntu 26.04 LTS and Debian 13. For each one you get the update commands, a way to tell whether a reboot is needed and the standard tool for automatic updates. The Ubuntu and Debian commands also apply to Ubuntu 24.04 LTS and Debian 12.
CentOS 7 reached end of life in June 2024, Ubuntu 16.04 left standard support in April 2021 and Debian 8 has been unsupported since 2020. Running the update commands on those releases no longer brings security fixes, because none are published for them. The fix there is a migration to a supported release: AlmaLinux or Rocky Linux in place of CentOS, and the current Ubuntu LTS or Debian stable in place of the old ones.
Before you update
- Log in as a user with
sudorights. - Make sure you have a current backup or snapshot, especially before a kernel or database update.
- On a remote server, run long updates inside
tmuxorscreenso a dropped SSH connection does not interrupt the package manager. - Pick a quiet period. Updated services are restarted, and a new kernel only takes effect after a reboot.
Update AlmaLinux 9, Rocky Linux 9 or CentOS Stream 9
The package manager on the RHEL 9 family is dnf. The yum command still exists, but only as a link to it. Adding the EPEL repository, as tutorials for CentOS 7 often did, is not required for updating the system.
List the updates that are available. The command exits with status 100 when there are updates and 0 when there are none, which is useful in scripts:
sudo dnf check-update
Install all updates:
sudo dnf upgrade --refresh
--refresh forces fresh repository metadata before the transaction. Review the list and confirm with y. To install only updates that fix a security issue:
sudo dnf upgrade --security
Check whether a reboot is needed
The needs-restarting plugin reports whether core components such as the kernel or glibc were updated since boot:
sudo dnf install dnf-utils
sudo dnf needs-restarting -r
It exits with status 1 and says so when a reboot is required. sudo dnf needs-restarting -s lists the services that still run old code and only need a restart. Reboot when required:
sudo systemctl reboot
Automatic updates
Install dnf-automatic, review /etc/dnf/automatic.conf (set upgrade_type = security to limit it to security updates), and enable the timer that matches what you want. dnf-automatic-install.timer downloads and installs updates, dnf-automatic-download.timer only downloads them and dnf-automatic-notifyonly.timer only reports them:
sudo dnf install dnf-automatic
sudo systemctl enable --now dnf-automatic-install.timer
Update Ubuntu 26.04 LTS
Refresh the package index, then install the updates:
sudo apt update
sudo apt upgrade
apt upgrade installs new versions and any new dependencies they need, but never removes an installed package. If some packages are reported as kept back and you want them installed even though that requires removing others, use:
sudo apt full-upgrade
Read the list of removals before you confirm. Afterwards, remove dependencies that are no longer needed, including old kernels:
sudo apt autoremove
To see what would be updated without changing anything, run apt list --upgradable after sudo apt update.
Check whether a reboot is needed
Ubuntu creates a flag file when an installed update needs a reboot:
[ -f /var/run/reboot-required ] && cat /var/run/reboot-required /var/run/reboot-required.pkgs
If the command prints a message and a list of packages, reboot with sudo systemctl reboot. No output means no reboot is pending. Ubuntu Server also runs needrestart after each upgrade, which restarts services that still use outdated libraries.
Automatic updates
The unattended-upgrades package is installed and enabled by default and applies security updates once a day. The switch is in /etc/apt/apt.conf.d/20auto-upgrades; behaviour such as Unattended-Upgrade::Automatic-Reboot (off by default) and Unattended-Upgrade::Automatic-Reboot-Time is set in /etc/apt/apt.conf.d/50unattended-upgrades. Test your configuration without changing the system, and read the results of real runs in /var/log/unattended-upgrades/:
sudo unattended-upgrade -v --dry-run
Update Debian 13
Debian uses the same commands:
sudo apt update
sudo apt upgrade
Use sudo apt full-upgrade when an update needs to remove or replace packages, and clean up afterwards with sudo apt autoremove. Within a stable release, updates are security fixes and corrections collected in point releases, so the normal upgrade is almost always sufficient. If your account is not in the sudo group, which can be the case on a minimal Debian installation, switch to root with su - and run the commands without sudo.
Check whether a reboot is needed
The simplest check that works on every Debian system is to compare the running kernel with the newest installed one:
uname -r
ls /boot/vmlinuz-*
If a newer version is listed in /boot than the one uname -r prints, reboot to start using it. For services, install needrestart; it runs after each upgrade and can also be called by hand:
sudo apt install needrestart
sudo needrestart
Once unattended-upgrades is installed (next section), kernel updates also create the /var/run/reboot-required flag file, exactly as on Ubuntu.
Automatic updates
Install unattended-upgrades and enable the daily run with the configuration dialog; answer Yes:
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
The default configuration in /etc/apt/apt.conf.d/50unattended-upgrades covers Debian's stable and security archives. Put your own changes, such as enabling Unattended-Upgrade::Automatic-Reboot, in a separate file that sorts later, for example /etc/apt/apt.conf.d/52unattended-upgrades-local, and test with sudo unattended-upgrade -v --dry-run.
After the update
Confirm that the system came back in a healthy state:
uname -r
systemctl --failed
The first command shows the running kernel; the second lists services that failed to start and should print none. If an update on the RHEL 9 family causes a problem, sudo dnf history lists past transactions and sudo dnf history undo ID reverses one of them. On Ubuntu and Debian, /var/log/apt/history.log records what each run changed.
Frequently asked questions
How often should I update a server?
Let security updates install automatically every day and run a full manual update on a schedule you can supervise, for example weekly or monthly, with a reboot when one is pending. An update that waits for months is the usual way a known vulnerability stays open.
Is it safe to add -y and reboot automatically after every update?
-y answers every question for you, including the one that would remove packages during a full-upgrade. It is fine in scripts you have tested, but read the summary when updating by hand. Rebooting unconditionally is unnecessary: check whether a reboot is required and schedule it for a quiet moment.
Do these commands move me to the next release?
No. They update packages within the installed release, for example from one AlmaLinux 9 minor release to the next, or between Debian 13 point releases. Moving to a new major release, such as Ubuntu 24.04 to 26.04 or Debian 12 to 13, is a separate, documented upgrade procedure.
What is the difference between dnf update and dnf upgrade?
None in effect. update is a deprecated alias of upgrade kept for people used to yum. Use upgrade in new scripts.