
Ubuntu’s Update Manager makes it relatively easy to upgrade your installation to a new major release. The utility’s graphical interface guides you through a step-by-step wizard that should be easy to follow.
But there are times when you cannot use a graphical utility – for example, on servers you don’t have access to a graphical interface. In this case you are forced to use the command line to upgrade Ubuntu.
However, this is not the only scenario where this is useful. The command line interface usually lets you see more about what is going on. Most command line utilities output a lot of text while they work. Consequently, you might prefer this method if you want to see the details of the upgrade as it happens. You can also more easily spot potential errors if they arise.
do-release-upgrade Command Line Switch “-d”
The utility to upgrade Ubuntu from a previous version to an upgraded version is called do-release-upgrade
. It’s actually a script written in the Python programming language.
Normally, the script will upgrade from one stable release (or LTS – Long-Term Support) to the next. For example, it might update Ubuntu 16.04 to Ubuntu 18.04. However, when a new LTS version appears, you cannot upgrade to it until its first point release. What this means is that if you’re currently using 16.04.5, you can’t upgrade to 18.04. You have to wait until 18.04.1 is launched. It’s recommended to actually wait for the first point release. The first new LTS release might still hide nasty bugs, but if you really need the new LTS, as soon as it comes out you can use a command line switch to force the utility to upgrade. So if 18.04 just came out, you can upgrade with
sudo do-release-upgrade -d
before 18.04.1 comes out. Otherwise, if 18.04.1 is already available, use the command without the switch:
sudo do-release-upgrade
How to Upgrade Ubuntu with do-release-upgrade Command
Before the upgrade it’s recommended that you temporarily disable any third-party repositories, such as PPAs or entries you added in “/etc/apt/sources.list” or “/etc/apt/sources.list.d/.” If you know you didn’t add any repositories from other providers except Ubuntu, you can, of course, skip this step.
Some packages from these repositories might interfere in unexpected ways with new packages from the next Ubuntu release. Afterwards, run sudo apt update
to refresh package information. Then, use a command such as sudo apt autoremove nginx
to remove programs you have installed from third-party providers.
If the do-release-upgrade
command is not available on your system, install it with
sudo apt install update-manager-core
It’s usually installed by default though.
Your software packages have to be up to date before upgrading to a new Ubuntu release. Update all packages on your system.
sudo apt update && sudo apt upgrade
Upgrading to Short-Term Support Ubuntu (Optional)
Even numbers, such as 18.04, indicate a long-term support release (LTS). Odd numbers, such as 19.04, indicate a development, short-term support release. If you’re currently on an LTS version and want to upgrade to the next LTS, skip the steps in this section. But if you’re currently on an LTS version, such as 18.04, and want to upgrade to 18.10 or 19.04 (whichever is the next available), edit this file:
sudo nano /etc/update-manager/release-upgrades
Change Prompt=lts
to Prompt=normal
. Press Ctrl + X, then y followed by Enter to save the file.
If You’re Upgrading Your Local Computer
Although you can open a terminal emulator on your graphical desktop, this presents a problem. When the graphical server gets upgraded, it might get restarted. This would, in turn, make you lose your terminal session, so it’s better to log out from your graphical session. Afterward, press Alt + Ctrl + F2 or Alt + Ctrl + F3 and log in on the TTY console before starting the upgrade script below.
Start Ubuntu Upgrade
Simply start the upgrade script.
sudo do-release-upgrade
Now, carefully follow the steps in the wizard. They will be slightly different depending on your upgrade scenario. For example, when connected to an SSH session, you will get an extra step like the one in the following image.
In later steps you will almost certainly be asked what to do with configuration files that have changed in new package versions.
If you have changed the mentioned configuration file, you might want to type “N” to keep your changes. The same is true if your server provider has made changes to those files. This is something that you will have to investigate yourself. If you or your provider didn’t make any special changes, type “Y” to pull in the updated configuration file.
Conclusion
The upgrade process is not complicated, but complications may arise. It usually depends a lot on how “clean” your system is (no third-party repositories). After the upgrade utility finishes its job, all you have to do is reboot your machine. Normally, the script will give you the option to reboot, but if it doesn’t, you can just run:
sudo systemctl reboot
or simply:
sudo reboot
Provided you don’t run into any upgrade bugs or bugs with new software installed, everything will work perfectly once the machine is rebooted.
Our latest tutorials delivered straight to your inbox