How to Update a CentOS Server
This guide explains how to update the packages on your CentOS server, how to tell whether a reboot is needed and how to have updates installed automatically. If your server runs CentOS Linux 6, 7 or 8, read the section on versions that are no longer supported first.
Which version are you using?
cat /etc/redhat-release
The output looks like CentOS Stream release 9 or CentOS Linux release 7.9.2009 (Core).
Support status of the versions
| Version | Security updates until | Status (November 2026) |
|---|---|---|
| CentOS Stream 10 | Around 2030 | Supported |
| CentOS Stream 9 | 31 May 2027 | Supported |
| CentOS Stream 8 | Ended 31 May 2024 | Not supported, repositories archived |
| CentOS Linux 8 | Ended 31 December 2021 | Not supported, repositories archived |
| CentOS Linux 7 | Ended 30 June 2024 | Not supported, repositories archived |
| CentOS Linux 6 | Ended 30 November 2020 | Not supported, repositories archived |
CentOS Stream is the version where the next minor release of Red Hat Enterprise Linux is developed; it receives updates continuously.
Before you start
- Run the commands as root or with
sudo. - Take a backup. Backups are the customer's responsibility; for your server you can use our backup services or take a copy of the whole server with the System Copy add-on.
- Choose a quiet time. Some services restart during the update, and a kernel update needs a reboot.
- If you lose your SSH connection, you can still reach a VDS server from the console in the client area: Using the Console on a VDS Server.
Installing updates
- See which updates are available:
dnf check-update - Install them:
The command shows what it will do and asks for confirmation; press y and Enter. (dnf upgradednf updateis an older name for the same command.)
Security updates cannot be installed on their own on CentOS: the CentOS repositories do not publish security advisory data, so dnf upgrade --security reports that there is nothing to install even when there is. Always install all updates with dnf upgrade.
Is a reboot needed?
A new kernel or core libraries (such as glibc or systemd) only take effect after a reboot. Check with:
dnf needs-restarting -r
The command says whether a reboot is needed. If it is not found, install it with dnf install dnf-plugins-core. To list the services still using old files: dnf needs-restarting -s. To reboot the server: reboot. You can also use Restart in the client area.
Installing updates automatically
dnf-automatic downloads and installs updates on a schedule. Install it:
dnf install dnf-automatic
Set these lines in the [commands] section of /etc/dnf/automatic.conf:
[commands]
upgrade_type = default
apply_updates = yes
Leave upgrade_type = default: these repositories do not publish security advisories, so the security setting would install nothing.
Turn on the timer:
systemctl enable --now dnf-automatic.timer
By default the server is not rebooted. If you want, reboot = when-needed in the same section reboots it when an update needs it.
Versions that are no longer supported
CentOS Linux 6, 7 and 8 and CentOS Stream 8 no longer receive any updates, including security fixes. Their packages have been moved to the vault.centos.org archive, so yum update / dnf upgrade fails on these servers with errors such as "Cannot find a valid baseurl" (CentOS 7) or "Failed to download metadata" (CentOS 8). The archive lets you install packages, but no new fixes arrive there.
On CentOS 7 the commands are yum check-update and yum update; whether a reboot is needed is checked with needs-restarting -r (yum-utils package), and automatic updates are done with yum-cron (/etc/yum/yum-cron.conf, apply_updates = yes). Since no updates are published any more, these tools will not bring new fixes either.
For a server that stays on the internet, the lasting solution is to move to a supported system. AlmaLinux and Rocky Linux are close relatives of CentOS; their version 10 is supported until 2035. If you would like your server reinstalled with a current system, you can open a support ticket from your client area.
Troubleshooting
- "Waiting for process with pid … to finish": another dnf process is running (often the automatic update). Wait for it to finish.
- "Cannot download repomd.xml" or "Failed to download metadata": check the server's internet and DNS settings, then try again with
dnf clean allanddnf upgrade. - The server does not come back after a reboot: open the console in the client area and check the screen (Using the Console on a VDS Server). The boot menu usually still has the previous kernel. If you cannot solve it, you can open a support ticket from your client area.
The information in this guide is taken from official documentation: CentOS Linux EOL, CentOS Linux vs CentOS Stream, CentOS Stream 10, CentOS Vault, dnf command reference, dnf needs-restarting, dnf-automatic, needs-restarting(1), yum-cron.conf.