Updating your Ubuntu VPS

Reading Time: 2 minutes

Applying the latest operating system and security updates to your Ubuntu VPS is very simple. If possible, you’ll want to check for updates weekly. You should check at least once a month. There are just three simple commands that you have to run.

The first command that you’ll run will download information about what updates are available. Here is the command:

apt update

A lot of information will be displayed in your SSH session. Most of it is not important (it’s just showing the progress of the download). You’ll want to pay attention to the last few lines. Here is sample output:

Reading package lists… Done
Building dependency tree
Reading state information… Done
31 packages can be upgraded. Run 'apt list --upgradable' to see them.

In this particular instance, there were 31 “packages” available for update, so you know you have updates that need to be applied.

Next, I would suggest that you get a list of the packages that need to be updated. You can do this by running the following command:

apt list --upgradable

Most Ubuntu updates do not require a reboot. The exception to that is if there is a “Kernel” update. By listing what updates are available, you can see if there are any packages where the name begins with “kernel”. If there are, you’ll need to reboot. If not, you can simply skip the reboot.

Here is sample output from the list command:

apt list --upgradable
Listing… Done
containerd.io/focal 1.4.6-1 amd64 [upgradable from: 1.4.4-1]
dnsmasq-base/focal-updates,focal-security 2.80-1.1ubuntu1.4 amd64 [upgradable from: 2.80-1.1ubuntu1.3]
docker-ce-cli/focal 5:20.10.7~3-0~ubuntu-focal amd64 [upgradable from: 5:20.10.6~3-0~ubuntu-focal]
docker-ce/focal 5:20.10.7~3-0~ubuntu-focal amd64 [upgradable from: 5:20.10.6~3-0~ubuntu-focal]

Note: The package name is at the beginning of each line.

Finally, you need to apply the updates to your VPS. You can do this by running the following command:

apt upgrade

The output of the command will vary depending on what and how many packages are being updated, but it will always end with these few lines:

31 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 316 MB of archives.
After this operation, 385 MB of additional disk space will be used.
Do you want to continue? [Y/n]

The output will show you how many packages will be upgraded (31 in this case), how many new packages will be installed (5 in this case) and how many obsolete packages will be removed (0 in this case).

To apply the updates, type “Y” and press enter.

You will then see the updates being downloaded and then applied. While the updates are being applied, you will see a progress bar at the bottom of your SSH session. Depending on the number of updates, this process can take a few seconds or a few minutes. Just be patient and let the process finish.

The final step (if required) would be to reboot your VPS. You can reboot your VPS with the following command:

shutdown -r now

The above command tells Ubuntu to shut down, reboot (-r) and do it now (now).

You have now applied the latest updates and security updates to your Ubuntu VPS.