# How to Update Your Linux Server

Source: https://lyrahosting.com/how-to/how-to-update-your-linux-server/

1. [Home](https://lyrahosting.com/)
2. [How-to](https://lyrahosting.com/how-to/)
3. How to Update Your Linux Server

How-to

Written by [the LyraHosting technical team](https://lyrahosting.com/about-us/#team) · Reviewed by Erik, certified Linux system administrator (LFCS) · Published 7 Nov 2026 · Updated 11 Nov 2026 · 5 min read

This guide installs software updates on a Linux server, on a VPS or a dedicated server. It covers Ubuntu and Debian (apt) and Red Hat-family systems such as RHEL, AlmaLinux and Rocky Linux (dnf). You install the updates, check whether the server needs a restart, and can then let the server install security updates on its own.

Update a new server before you put it to work, and keep updating it after that. Updates bring security fixes as well as bug fixes.

## Before you start

You need SSH access as root or as a user who can use `sudo`. The commands below use `sudo`; leave it out when you are logged in as root.

- A backup. An update rarely breaks a server, but a backup is your way back if one does. On a LyraHosting [Linux VPS](https://lyrahosting.com/offshore-linux-vps/), daily snapshots are available as an optional add-on. Keep a copy of important data off the server too.
- A way back in. If the server doesn't come back after a restart, you need another route to it. The control panel of a LyraHosting Linux VPS has a VNC or serial console and can boot the rescue system. Every LyraHosting [dedicated server](https://lyrahosting.com/offshore-dedicated-servers/) includes IPMI, which works even when the operating system doesn't respond.

Run long updates inside `tmux` or `screen`, so they carry on if your SSH connection drops.

## How to update Ubuntu and Debian

Ubuntu and Debian install software with APT.

1. Refresh the package lists first, then install the updates:

```
sudo apt update
sudo apt upgrade
```

2. Read the list of what will change, and confirm.

`apt update` downloads the current package information from the sources configured on the server. `apt upgrade` then installs the newer versions of your installed packages. It adds new packages when an update depends on them, but it never removes one: an update that would need a removal is left out.

To install those updates as well, run a full upgrade. It may remove packages, so read the list of removals before you go ahead:

```
sudo apt full-upgrade
```

On Ubuntu, `apt upgrade` sometimes reports that packages "have been kept back". This is often a phased update: Ubuntu gives some updates to a small share of machines first and widens the rollout once they prove stable. You don't need to do anything, and security updates are never phased.

Packages that were installed only as dependencies can become unused after updates. `sudo apt autoremove` removes them. Check its list first, because it can include a program you still use.

Older guides join these commands into one line with `-y`, which answers yes to every question. On a live server, run them one at a time and read what each will change. In scripts, use `apt-get`: [the APT manual](https://manpages.debian.org/trixie/apt/apt.8.en.html) describes `apt` as a tool for people at a terminal, whose behavior may change between versions.

## How to update RHEL, AlmaLinux and Rocky Linux

Red Hat-family systems install software with DNF, the successor to YUM. CentOS Stream uses it too.

1. List the available updates:

```
sudo dnf check-update
```

2. Then install them:

```
sudo dnf upgrade
```

`dnf update` is an older name for the same command. Older guides use `yum update`; for everyday commands DNF works the same way, so use `dnf`.

CentOS Linux is a different case. CentOS Linux 7 reached the end of its life at the end of June 2024, and the CentOS Project took its mirror list service offline at the same time, so a CentOS Linux 7 server gets no more updates. Move what runs on it to a supported release, such as AlmaLinux, Rocky Linux, Ubuntu or Debian.

## Check whether the server needs a restart

A running program keeps using the old version of an updated file until it restarts. A service picks up an updated library when you restart that service; a new kernel takes effect only after a reboot of the server.

On Ubuntu, an update that needs a reboot leaves the file `/run/reboot-required` (also reached as `/var/run/reboot-required`). If this command finds it, restart the server:

```
ls /run/reboot-required
```

On Ubuntu and Debian, the needrestart tool finds services that still run old code. It runs on its own after APT installs updates, and since Ubuntu 24.04 it restarts the affected services by default. To check by hand:

```
sudo needrestart -r l
sudo needrestart -k
```

The first command lists the services that need a restart, without restarting them. The second checks only whether a newer kernel is waiting for a reboot. If the tool is missing, install it with `sudo apt install needrestart`.

On RHEL, AlmaLinux and Rocky Linux, the needs-restarting plugin answers the same questions:

```
sudo dnf needs-restarting -r
sudo dnf needs-restarting -s
```

The first command reports whether a reboot is needed; the second lists the services to restart. The plugin is part of the dnf-plugins-core package, so install that with `sudo dnf install dnf-plugins-core` if the command is missing.

Restart a single service with `sudo systemctl restart` followed by its name, or the whole server with `sudo reboot`. After a reboot, give the server a minute, log in again and check that your websites and services work.

## Turn on automatic security updates

Ubuntu does this already. The [unattended-upgrades package is installed by default](https://ubuntu.com/server/docs/how-to/software/automatic-updates/) and installs security updates once a day. Its settings are in `/etc/apt/apt.conf.d/50unattended-upgrades`. It doesn't reboot the server unless you set `Unattended-Upgrade::Automatic-Reboot "true";` in that file.

Debian uses the same package. Install it and switch it on:

```
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
```

By default it installs only security updates, and it logs its work in `/var/log/unattended-upgrades/`.

RHEL, AlmaLinux and Rocky Linux use DNF Automatic:

```
sudo dnf install dnf-automatic
```

To limit it to security updates, set `upgrade_type = security` in the `[commands]` section of `/etc/dnf/automatic.conf`. Then enable the timer that downloads and installs updates:

```
sudo systemctl enable --now dnf-automatic-install.timer
```

If you'd rather install updates yourself, enable `dnf-automatic-notifyonly.timer` to be told about new updates, or `dnf-automatic-download.timer` to have them downloaded in advance. Recent versions can also reboot the server after updates through the `reboot` option in the same file, which is set to `never` by default.

In this article

1. [Before you start](https://lyrahosting.com/how-to/how-to-update-your-linux-server/#before-you-start)
2. [How to update Ubuntu and Debian](https://lyrahosting.com/how-to/how-to-update-your-linux-server/#how-to-update-ubuntu-and-debian)
3. [How to update RHEL, AlmaLinux and Rocky Linux](https://lyrahosting.com/how-to/how-to-update-your-linux-server/#how-to-update-rhel-almalinux-and-rocky-linux)
4. [Check whether the server needs a restart](https://lyrahosting.com/how-to/how-to-update-your-linux-server/#check-whether-the-server-needs-a-restart)
5. [Turn on automatic security updates](https://lyrahosting.com/how-to/how-to-update-your-linux-server/#turn-on-automatic-security-updates)

Keep exploring [All how-to guides](https://lyrahosting.com/how-to/) [Talk to our team](https://lyrahosting.com/contact-us/)

## Host it offshore with LyraHosting

KVM virtual servers in the Netherlands with full root access, from €8.99 a month.

[Explore offshore VPS](https://lyrahosting.com/offshore-linux-vps/) [Contact us](https://lyrahosting.com/contact-us/)

Keep reading

## More from the how-to

[View all](https://lyrahosting.com/how-to/)

01 / From the journal

How-to · 7 Nov 2026

### [How to Change the SSH Port on a Linux Server](https://lyrahosting.com/how-to/how-to-change-the-ssh-port/)

Move SSH off port 22 on Ubuntu, Debian, RHEL, AlmaLinux or Rocky Linux without locking yourself out: firewall, SELinux, ssh.socket, test login.

5 min read [Read article](https://lyrahosting.com/how-to/how-to-change-the-ssh-port/)

02 / From the journal

How-to · 7 Nov 2026

### [How to Change the Root Password on a Linux Server](https://lyrahosting.com/how-to/how-to-change-the-root-password/)

Change the root password on Ubuntu, Debian, RHEL, AlmaLinux or Rocky Linux with passwd, pick a strong one, and see why SSH keys are safer.

4 min read [Read article](https://lyrahosting.com/how-to/how-to-change-the-root-password/)

03 / From the journal

How-to · 9 Jun 2022

### [How to Change the IP Address of a Linux Server](https://lyrahosting.com/how-to/how-to-change-ip-address-of-your-server/)

Change a Linux server's IP address on Ubuntu, Debian, RHEL, AlmaLinux or Rocky Linux: test the new address first, then make it permanent.

5 min read [Read article](https://lyrahosting.com/how-to/how-to-change-ip-address-of-your-server/)
