Unlike Ubuntu, AlmaLinux and Rocky Linux do not install updates by themselves after the installation. This page shows how to install updates by hand, how to let the server install security updates every day with dnf-automatic, and how to find out whether a restart is needed. The commands were tested on a dedicated server with AlmaLinux 9 and in test machines with Rocky Linux 9 and AlmaLinux 10; run them as root.


Install All Updates Now

dnf upgrade

dnf lists what it will update and asks for confirmation; answer y. To see first what is waiting, without installing anything: dnf check-update. Only the security fixes: dnf updateinfo list --security lists them, and dnf upgrade --security installs only them.

Is a Restart Needed?

Some updates, such as a new Linux kernel, only take effect after a restart:

dnf needs-restarting -r

If a restart is needed, the answer starts with Core libraries or services have been updated since boot-up and ends with Reboot is required to fully utilize these updates. Otherwise it says Reboot should not be necessary. Restart with reboot at a time that suits you. For a dedicated server, see also How to Reboot Your Dedicated Server; for a VPS, the Client Area has Information → Restart (see the VPS Client Area Quick Start Guide).

Install Security Updates Every Day

dnf install dnf-automatic

Open /etc/dnf/automatic.conf with nano and change two lines under [commands]:

upgrade_type = security
apply_updates = yes

upgrade_type = security installs only security fixes; with default it installs all updates. Then switch on the daily run:

systemctl enable --now dnf-automatic.timer
systemctl list-timers dnf-automatic.timer

The timer runs every day at 6:00 server time, with a random delay of up to one hour. The second line shows when it runs next. To test it now, start one run by hand and read its log:

systemctl start dnf-automatic.service
journalctl -u dnf-automatic.service -n 20

Its log ends, for example, with Upgrade 13 Packages and Updates completed at ….

Restart Automatically When Needed

If you prefer the server to restart by itself after an update that needs it, set this line in /etc/dnf/automatic.conf, also under [commands]:

reboot = when-needed

dnf-automatic then restarts the server after such an update, five minutes after the run (reboot_command in the same file), so in the morning between 6:00 and a little after 7:00 server time. A run that installs a new kernel starts the restart command at once. The time is the server's own time zone, which is UTC after a standard installation; timedatectl shows yours.

To run the updates, and with them the restarts, at another time, give the timer a time of its own:

systemctl edit dnf-automatic.timer

Write these lines in the empty part at the top, save and close the editor. The empty OnCalendar= removes the old time:

[Timer]
OnCalendar=
OnCalendar=*-*-* 04:00

systemctl list-timers dnf-automatic.timer then shows the next run at 04:00 plus the random delay, for example at 04:13:55.

💡 Programs that must keep running

Make sure your own programs start again after a restart: Keep a Program Running on Linux. On AlmaLinux and Rocky Linux, keep the scripts that a service starts in /usr/local/bin, not in a home folder; see SELinux on AlmaLinux and Rocky Linux.


Related Guides

View all AlmaLinux and Rocky Linux guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)