There are several ways to upgrade a Linux installation. With Ubuntu, the recommended upgrade method is to use the do-release-upgrade command. This command is the official method for upgrading the Ubuntu version.

Ubuntu Upgrade Command

Canonical has built a native method for upgrading an Ubuntu installation in an automatic fashion. This basically is a script that automates all the Debian commands that would otherwise be necessary to upgrade to a newer release of Ubuntu; thus making it really easy to run.

All you need to do is run the do-release-upgrade command using sudo, like the following:

sudo do-release-upgrade

When executing this command, the Ubuntu version upgrade will be kicked off. Keep in mind that you will be prompted a couple times to accept things along the way. So, running this command (like stated above) wont be able to be run completely in the background without user action.

After this command has finished executing, your Ubuntu installation will be upgraded to the latest release.

This is the recommended way to upgrade Ubuntu Server edition installations. This does not have any graphical dependencies, so it can be run on both Ubuntu Server and Ubuntu Desktop! Additionally, this tool is installed by default with Ubuntu. If you find it’s not available on your installation, then reference the description below on how to install it.

“For further stability of an LTS release, there is a slight change in behavior if you are currently running an
LTS version. LTS systems are only automatically considered for an upgrade to the next LTS via do-release-upgrade with the first point release. So for example 18.04 will only upgrade once 20.04.1 is released. If you
want to update before, e.g. on a subset of machines to evaluate the LTS upgrade for your setup the same
argument as an upgrade to a dev release has to be used via the -d switch.”

Source: Official Ubuntu Server Guide

Upgrade to Development Version

If for some reason you get a No new release found message, then append the -d flag to the command to essentially force an upgrade to a development version of Ubuntu. This is not a flag you’ll want to use in a Production environment, unless you are fully aware of the potential consequences.

sudo do-release-upgrade

Caution: It is not recommended to use the -d flag and upgrading to a development release when upgrading a Production system.

Prerequisite: update-manager-core Package

The Ubuntu do-release-upgrade command is made available as part of the update-manager-core package. As a result, the Ubuntu system will need to have this package installed prior to being able to run the upgrade command.

Keep in mind that the update-manager-core package is installed by default with Ubuntu, so it should be already installed. In case it’s not installed, you can install this package as follows:

sudo apt install update-manager-core

Update Packages First

It’s a good practice to update all your installed packages first. This is done using the traditional apt-get update and upgrade commands. You can also use the dist-upgrade command to update the distribution.

It’s recommended to run these commands first, prior to performing an upgrade to a newer version of Ubuntu. This should help reduce compatibility issues, and get you closer to a state that more closely mirrors the test cases the Canonical team uses for testing upgrades.

To update and upgrade all the installed packages on your Ubuntu installation, run these commands:

sudo -s 
apt update
apt upgrade
apt dist-upgrade

Happy upgrading!

Microsoft MVP

Chris Pietschmann is a Microsoft MVP, HashiCorp Ambassador, and Microsoft Certified Trainer (MCT) with 20+ years of experience designing and building Cloud & Enterprise systems. He has worked with companies of all sizes from startups to large enterprises. He has a passion for technology and sharing what he learns with others to help enable them to learn faster and be more productive.
HashiCorp Ambassador Microsoft Certified Trainer (MCT) Microsoft Certified: Azure Solutions Architect