Skip to content
HOSTIGAN
Server administration

How to update Ubuntu Server safely

A safe routine for updating Ubuntu Server: apt update and upgrade, automatic security updates, reboots and needrestart, Livepatch, snapshots and release upgrades.

Intermediate 5 min read Updated November 24, 2026

Security holes in Linux packages are found and fixed all the time. An Ubuntu server that is not updated becomes easier to break into week by week, and many successful attacks exploit vulnerabilities that were patched long before. Updating is not hard, but doing it safely means knowing what each command does, when a reboot is needed and how to get back if something goes wrong.

This guide gives you a routine for Ubuntu Server 24.04 LTS: manual updates with apt, automatic security updates, reboots, Livepatch, snapshots and upgrading to the next LTS release.

How updates work on Ubuntu

Ubuntu updates in two stages:

  1. Refresh the package lists to learn what new versions exist.
  2. Install the new versions of the packages you have.

In an LTS release, Ubuntu does not swap in new major versions of software. Updates are security and bug fixes, which is why they are normally safe to install. The safe routine is:

  1. Make sure you have a working backup or snapshot.
  2. sudo apt update
  3. sudo apt upgrade
  4. Check whether a reboot is required.
  5. Confirm services are running and logs are clean.

apt update, upgrade and full-upgrade

sudo apt update          # fetch package lists; installs nothing
apt list --upgradable    # see what would change
sudo apt upgrade         # install updates, never removes packages

apt upgrade is the everyday command. Occasionally an update needs to install a new dependency or remove an old one, and upgrade holds that package back. full-upgrade handles those cases:

sudo apt full-upgrade

Read its summary before you answer yes, especially the list of packages it will remove. Afterwards, clear out packages nothing needs any more, such as old kernels:

sudo apt autoremove

Phased updates and held packages

You may see The following upgrades have been deferred due to phasing. Ubuntu rolls some updates out to a growing share of machines over several days, so a bad update can be stopped early. That is normal; the update arrives on its own.

A package can also be held on purpose. List holds with:

apt-mark showhold
sudo apt-mark unhold PACKAGE_NAME

Automatic security updates with unattended-upgrades

Ubuntu Server ships with unattended-upgrades, which installs security updates once a day. Check that it is installed and switched on:

systemctl status unattended-upgrades
cat /etc/apt/apt.conf.d/20auto-upgrades

You want to see:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

If the file is missing or set to "0", enable it with sudo dpkg-reconfigure -plow unattended-upgrades. Do a dry run to see what it would do:

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

The main settings live in /etc/apt/apt.conf.d/50unattended-upgrades. Rather than edit that file, which a package update may want to replace, put your own choices in a separate file that is read after it:

sudo nano /etc/apt/apt.conf.d/52unattended-upgrades-local
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";

Automatic reboots are a trade-off: you get kernel fixes without remembering, at the cost of a minute of downtime at a time you choose. Leave them off if the server runs something that must not restart unattended.

Logs are in /var/log/unattended-upgrades/, and every apt run is recorded in /var/log/apt/history.log.

Note: By default unattended-upgrades only installs updates from Ubuntu's security pocket. Packages from third-party repositories, such as Docker or nginx.org, need your regular manual apt upgrade.

Reboots, kernels and needrestart

Most updates take effect when the affected service restarts. Kernel updates, and some core libraries, need a full reboot. Ubuntu tells you in two ways:

cat /var/run/reboot-required           # exists only when a reboot is needed
cat /var/run/reboot-required.pkgs      # which packages asked for it
uname -r                               # the kernel that is running now

The login message also shows *** System restart required ***.

For services, Ubuntu 24.04 uses needrestart, which runs after every apt operation and restarts services that still use old versions of updated libraries. To see what still runs outdated code:

sudo needrestart -r l

After a reboot, check that everything came back:

systemctl --failed
journalctl -p err -b

If you need to restart a VPS from outside, see how to restart, shut down and manage your VPS.

Livepatch: kernel fixes without rebooting

Canonical Livepatch applies fixes for critical kernel vulnerabilities to the running kernel, so you can postpone the reboot. It is part of Ubuntu Pro, which also extends security maintenance (ESM) to more packages and to ten years in total. Ubuntu Pro is free for personal use on a small number of machines.

sudo pro attach YOUR_TOKEN
sudo pro enable livepatch
canonical-livepatch status

Livepatch does not cover every fix, so you still need to reboot into new kernels regularly. It buys time; it does not replace reboots.

Back up before you update

Everyday security updates rarely cause trouble. full-upgrade, third-party packages and release upgrades are where things can break, so prepare:

  • Check that backups actually work, not just that they run.
  • Take a snapshot if your platform offers one. It is the fastest way back.
  • Copy /etc, which holds all configuration, as a light extra safety net:
sudo tar czf /root/etc-$(date +%F).tar.gz /etc
  • Pick a quiet time and leave yourself time to follow up afterwards.

Upgrading to a new LTS release

A new Ubuntu LTS arrives every two years. Upgrading in place is supported but is a bigger job than a normal update:

  1. Take a full backup or snapshot.
  2. Bring the current release fully up to date with sudo apt update && sudo apt full-upgrade, then reboot.
  3. Check that /etc/update-manager/release-upgrades contains Prompt=lts.
  4. If a firewall is active, allow the fallback SSH port the upgrader opens: sudo ufw allow 1022/tcp.
  5. Run the upgrade inside tmux or screen so a dropped SSH connection does not stop it, then start it with sudo do-release-upgrade.
  6. Afterwards, check lsb_release -a, re-enable any third-party repositories the upgrader disabled, and remove the temporary firewall rule.

Upgrade one LTS at a time; you cannot skip a release. LTS-to-LTS upgrades are normally offered once the first point release of the new version is out.

When an update goes wrong

If a service will not start after an update, read its log first with journalctl -u SERVICE_NAME -n 100. Often a configuration file needs a small change for the new version, and apt may have saved your old file next to the new one with a .dpkg-old or .dpkg-dist extension. Compare them with diff before you choose. If you cannot fix it quickly and you took a snapshot, roll back, then test the update again on a copy of the server.

A sensible update rhythm

How oftenWhat
DailyAutomatic security updates via unattended-upgrades
Weeklyapt update && apt upgrade, check for pending reboots
MonthlyPlanned reboot, apt autoremove, read the logs
Every two years or soPlan the move to the next LTS release

In short

Run apt update and apt upgrade weekly, let unattended-upgrades handle security updates daily, and reboot when /var/run/reboot-required appears. Read full-upgrade output before you confirm, take a snapshot before big changes and upgrade releases one LTS at a time. Pair updates with a firewall and hardened SSH, and work through the VPS security checklist. New to the terminal? Start with the essential Linux commands.

Updating a Hostigan VPS

A Hostigan VPS comes with Ubuntu, Debian, AlmaLinux or Rocky Linux and full root access, so you are in charge of the update routine. On VPS Plus and up you can take a snapshot before a full-upgrade or release upgrade and roll back if something does not come back as expected.

Frequently asked questions

Let unattended-upgrades install security updates every day, and run a manual apt update and apt upgrade at least once a week. Plan a reboot whenever a new kernel is waiting.

Next in “Get started with a VPS” · 9 of 11How to configure a firewall on your Linux VPS