How to upgrade Ubuntu server 20.04 to 22.04

Ubuntu 22.04 is loaded with many important new features that make it one of the releases of the year. However, Ubuntu 20.04 was a good version that is at a significant point of maturity, so doubts arise.

Despite the doubts, it is always good to have the recent new features that Ubuntu releases have to offer. Some of them are essential for various systems because they include new versions of libraries, web servers, programming languages, and so on.

To mitigate the doubts is that this post has been created, so you can update Ubuntu without problems and with a very safe process that comes from the distribution itself.

How to upgrade Ubuntu Server 20.04 to 22.04

The process is simple and secure. However, it is always a good idea to have a backup of your most sensitive data to avoid unnecessary risks.

First, connect via SSH to the server or open a terminal and update the system

sudo apt update
sudo apt upgrade

If you have root access, then you can also do this step from root.

The next step is to check the system version, this is done so that you can tell the difference at the end and is useful if you want to use it in scripts.

cat /etc/os-release

Sample output:

NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

When using an SSH session to perform the upgrade process, then the wizard itself will require another port to complete the process. So open 1022 which is the one used.

ufw allow 1022/tcp
ufw reload
ufw status

Normally, the update-manager-core package should be installed, but you’d better be sure

apt install update-manager-core

And now do the upgrade with the command

do-release-upgrade -d

One of the first things you will be asked about is the SSH session. You will be informed that another port is required, and it will suggest 1022 as you have already opened it, so accept the wizard solution.

Reading cache

Checking package manager

Continue running under SSH? 

This session appears to be running under ssh. It is not recommended 
to perform a upgrade over ssh currently because in case of failure it 
is harder to recover. 

If you continue, an additional ssh daemon will be started at port 
'1022'. 
Do you want to continue? 

Continue [yN] 

Continuing the process…

The process will then continue as normal, but you may see a screen like this where you will be asked if you want to automatically restart the services.

Restart Services during the upgrading
Restart Services during the upgrading

You will then be informed of the number of new packages to install and how long it may take.

Next, during the installation, you will be asked what to do with the SSH configuration. It is best to choose the option Keep the local version currently installed.

Keep the SSH configuration on the upgrading
Keep the SSH configuration on the upgrading

You will then be asked about obsolete packages and if you want to remove them.

Finally, if all goes well, you will see this message stating that the process was successful and that to enjoy the new system, you will need to reboot your computer.

When you reboot and log back in, you will be able to run the following again

cat /etc/os-release
Upgrade Ubuntu 22.04 from Ubuntu 20.04
Upgrade Ubuntu Server 22.04 from Ubuntu 20.04

And notice how you are now using Ubuntu 22.04.

Conclusion

An operating system upgrade is never too easy to tackle. However, as you have seen in this post, it is also not complex. In fact, more and more operating systems are evolving to make easier this process.

So, today you learned how to upgrade Ubuntu 20.04 to 22.04 using a terminal. Hope you like this post and please help us to grow up.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top