Update the system and packages on Ubuntu Server

How to update your Ubuntu server to the latest packages and security patches.

2 min
LinuxServerUpdateUbuntu

Updating your system on ubuntu logo Ubuntu server is a simple and essential step to ensure you have the latest security patches and packages.

1. Update Ubuntu package lists

bash logo
sudo apt update

This command updates the packages lists from the official ubuntu repositories, it does not update packages, just updates the list of available packages and their versions.

2. Upgrade the installed packages

bash logo
sudo apt upgrade

This command upgrades any outdated packages, will show you the exact list of packages that will be upgraded/deleted or kept back, and you will be asked to confirm before processing, it is always a good practice to read those carefully in production systems, make sure no critical package gets deleted or major software upgrade (breaking changes) gets installed.

If you just created this server, then there should be no issues, just type y and enter to confirm.

Output text logo
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-headers-6.17.0-14-generic linux-headers-6.8.0-101 linux-headers-6.8.0-101-generic linux-hwe-6.17-headers-6.17.0-14 linux-hwe-6.17-tools-6.17.0-14
  linux-image-6.17.0-14-generic linux-image-6.8.0-101-generic linux-modules-6.17.0-14-generic linux-modules-6.8.0-101-generic linux-modules-extra-6.17.0-14-generic
  linux-modules-extra-6.8.0-101-generic linux-tools-6.17.0-14-generic linux-tools-6.8.0-101 linux-tools-6.8.0-101-generic python3-python-discovery
The following packages have been kept back:
  ansible ansible-core
The following packages will be upgraded:
  linux-generic linux-generic-hwe-24.04 linux-headers-generic linux-headers-generic-hwe-24.04 linux-image-generic linux-image-generic-hwe-24.04 python3-virtualenv
7 upgraded, 15 newly installed, 0 to remove and 2 not upgraded.
6 standard LTS security updates
Need to get 397 MB of archives.
After this operation, 633 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Actual output might differ, depending on your installed packages.

3. Reboot the server (if needed)

In most cases a reboot is not needed, but if the kernel got upgraded, you need to reboot to use the new kernel. If that is needed you will see an output that contains a line like this:

Output text logo
Pending kernel upgrade!
Running kernel version:
  6.14.0-37-generic
Diagnostics:
  The currently running kernel version is not the expected kernel version 6.17.0-14-generic.

Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting.

You can use this command to check if a reboot is needed (if prints “Reboot is required” then you need to reboot, otherwise no reboot is needed):

bash logo
[ -f /var/run/reboot-required ] && echo "Reboot is required"

To reboot the server (if needed), run the following command:

bash logo
sudo reboot