Skip to content

Linux basicsFor beginnersDuration around 15 min.

How to update Ubuntu and upgrade to the next LTS release

A server only stays secure if it receives its updates. This guide shows the three stages: applying updates manually, running security updates automatically and switching to the next LTS release.

Tested on with Ubuntu 24.04.5 LTS and Ubuntu 26.04.1 LTS

At a glance

  • apt update fetches the package lists, apt upgrade applies the updates โ€” both always go together.
  • unattended-upgrades installs security updates automatically every day; you can schedule a required restart.
  • do-release-upgrade offers the switch to the next LTS as soon as its first point release is available โ€” from 24.04, this is 26.04.1.

Prerequisites

1. Apply updates

apt update only downloads the current package lists; nothing is installed yet. The second line shows what updates are available, the third applies them.

Fetch and update package lists
sudo apt update
apt list --upgradable
sudo apt upgrade

apt full-upgrade may also remove packages if a new dependency requires it โ€” for example, with a new kernel. For ongoing maintenance, apt upgrade is sufficient.

2. Check if a restart is required

New kernels and some libraries only take effect after a restart. Ubuntu then creates the file /var/run/reboot-required; the second file lists the packages that trigger it.

Check and execute restart
ls /var/run/reboot-required
cat /var/run/reboot-required.pkgs
sudo reboot

3. Remove old packages

Older kernels are left behind after kernel updates. autoremove removes packages that are no longer needed:

Clean up
sudo apt autoremove

4. Apply security updates automatically

unattended-upgrades applies security updates daily. It is already installed on many Ubuntu servers; the second command asks if it should run โ€” confirm with Yes.

Enable automatic updates
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades

Afterwards, these two lines are in the file:

/etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

An automatic restart is disabled. If the server should restart itself at night after a kernel update, remove the two slashes before these lines in /etc/apt/apt.conf.d/50unattended-upgrades and set the value to true:

/etc/apt/apt.conf.d/50unattended-upgrades
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "02:00";

A dry run shows what would be installed without changing anything:

Test run
sudo unattended-upgrade --dry-run --debug

5. Switch to the next LTS release

Create a backup before switching. Then apply all updates for the current release and restart โ€” do-release-upgrade requires a fully up-to-date system.

Prepare
sudo apt update
sudo apt full-upgrade
sudo reboot

A check run shows if a new release is available:

Search for a new release
do-release-upgrade -c
On Ubuntu 24.04
Checking for a new Ubuntu release
New release '26.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

The switch itself downloads and replaces almost all packages and asks questions in between, such as whether modified configuration files should be replaced. If it runs via SSH, the tool starts a second SSH service on port 1022 for safety.

Start the switch
sudo do-release-upgrade

Which releases are offered is specified in /etc/update-manager/release-upgrades. With Prompt=lts, a server only switches from LTS to LTS:

/etc/update-manager/release-upgrades
[DEFAULT]
Prompt=lts

Why only with the first point release

Ubuntu only offers the switch from LTS to LTS when the first point release of the new LTS is available. Until then, do-release-upgrade does not report a new release โ€” this is not an error.

Typical errors

  • Could not get lock /var/lib/dpkg/lock-frontend: Another package operation is running, often unattended-upgrades shortly after startup. Wait until it finishes instead of deleting the lock file.
  • Packages are kept back: Ubuntu distributes some updates in phases to a portion of the servers. They will arrive on their own after a few days; apt does not report an error.
  • Prompt about a modified configuration file: If you have modified the file yourself, keep your version and compare the new one at your leisure afterwards.
  • No new release found: Check Prompt in release-upgrades and whether all updates have been applied.

We tested all commands in this guide on 2 December 2026 โ€” with Ubuntu 24.04.5 LTS and Ubuntu 26.04.1 LTS. If a step changes at the manufacturer, we update it here along with the date.

Official documentation

Frequently asked questions about Ubuntu updates

What is the difference between apt update and apt upgrade?

apt update only downloads the list of available packages. apt upgrade then installs the newer versions โ€” which is why both commands always run one after the other.

How often should I update my server?

Security updates daily, most easily automated with unattended-upgrades. You install the remaining updates manually on a regular basis, for example once a week.

Does the server need to restart after every update?

No. A restart is mainly necessary after a new kernel; in that case, the file /var/run/reboot-required exists.

When can I switch from 24.04 to 26.04?

As soon as do-release-upgrade offers the new version, i.e. from the first point release 26.04.1. Ubuntu 24.04 receives standard support until 2029, so there is no rush to switch.

Can I undo a version upgrade?

Not with built-in tools. That is why you should create a backup before the switch, from which you can restore the old state.

Further reading

More tutorials

  • The scp command with examples: copy files over SSH

    Linux basicsFor beginnersabout 5 min

    scp copies files over an SSH connection โ€” encrypted, with the same credentials as your login, and without an additional service on the server. This guide shows the commands for common use cases, each with an example to copy.

  • How to check your Ubuntu version, codename and kernel

    Linux basicsFor beginnersabout 2 min

    A single command in the terminal shows which Ubuntu version is running on a server. Here are the common ways with their output โ€” for the version with point release, the codename, the kernel and the architecture.

  • How to remove a directory in Linux with rm and rmdir

    Linux basicsFor beginnersabout 5 min

    In Linux, you delete an empty folder with rmdir and a folder including its contents with rm -r. This tutorial shows both commands with their messages, the variants with and without prompting, and what to check before running rm -rf โ€” because there is no recycle bin in the terminal.

A server with Ubuntu LTS

VPS and cloud servers start with Ubuntu 24.04 LTS; keep it up to date with these commands.