...
Skip to main content
Print

How to Update Your Linux Server

You update an Ubuntu or Debian server with apt update and apt upgrade. On AlmaLinux you use dnf upgrade. Then check whether a reboot is needed. Updating regularly is the most important measure to keep your server secure. Most attacks exploit vulnerabilities for which an update has long been available.

Updating Ubuntu and Debian

apt update
apt upgrade -y

The first line fetches the latest package list, the second installs the updates.

Updating AlmaLinux

dnf upgrade -y

Is a reboot needed?

After a kernel update you need to restart the server. On Ubuntu you check that like this:

cat /var/run/reboot-required

On AlmaLinux you use dnf needs-restarting -r. Then restart with reboot.

Cleaning up old packages

apt autoremove -y
apt clean

Tips

  • Make a backup first: especially for major updates or an upgrade to a new version.
  • Automate security updates: read how to set up automatic updates.

Related articles

Table of Contents