1. Overview

Ubuntu is a Debian-based, open-source Linux distribution made for desktops, cloud computing, the Internet of Things (IoT), and enterprise servers, i.e., servers that collectively satisfy the requirements of an enterprise or a company instead of a single user.

As an Ubuntu user, we can optimize this Linux flavor in many ways to make it reach its full potential. One such way is upgrading to the newest available version on the Internet.

In this tutorial, we’ll discuss a step-by-step process to upgrade Ubuntu to the latest version.

2. Optimize Package List

The first step in the process is to optimize the package list on Ubuntu.

Firstly, we’ll update the package list on the distribution:

$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
Get:5 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
Get:7 http://security.ubuntu.com/ubuntu focal-security/main Translation-en
Get:8 http://security.ubuntu.com/ubuntu focal-security amd64 Contents (deb)
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main Translation-en
Get:10 http://archive.ubuntu.com/ubuntu focal-updates amd64 Contents (deb)
Fetched 444 MB in 7min 30s (988 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.

The apt command works as a package manager on Ubuntu and other Debian-based distros. When we combine it with the update command, it updates the package list on the distro and gives us a list of upgradable packages. Moreover, we have to be a root user to perform this operation, so we’ve used the sudo command.

As we can see, there are six packages that can be upgraded in this case.

So, let’s upgrade them using the apt upgrade command:

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libc-bin libc-dev-bin libc6 libc6-dev libx11-6 libx11-data
6 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
5 standard LTS security updates
Need to get 12.2 MB of archives.
After this operation, 102 kB of additional disk space will be used.
Do you want to continue? [Y/n] yes

We’ve typed yes in the terminal when prompted to continue with the package upgrade process.

After the process is complete, we’ll use the apt autoremove command to remove all the unnecessary packages from the distro and also utilize the –purge option to remove all of their configuration files too:

$ sudo apt autoremove --purge
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
  linux-image-4.15.0-45-generic* linux-headers-4.15.0-45*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 124 MB disk space will be freed.
Do you want to continue? [Y/n] yes
(Reading database ... 140963 files and directories currently installed.)
Removing linux-image-4.15.0-45-generic (4.15.0-45.48) ...
Removing linux-headers-4.15.0-45 (4.15.0-45.48) ...

Again, we’ve entered yes as an input to the prompt to continue with the removal procedure.

The package list is now optimized and hence, it’s time to proceed to the next step.

3. Install update-manager-core

The update-manager-core package is an essential component for upgrading Ubuntu from one version to another.

Before installing the package, we’ll reboot the distribution to ensure that it’s working fine:

$ sudo reboot

Then, we’ll install the package:

$ sudo apt install update-manager-core

Once the installation is complete, we can move on to the upgrade itself.

4. Upgrade Ubuntu to the Latest Version

We’ve already optimized the package list on Ubuntu, which helps prevent problems during the upgrade process. Moreover, we’ve installed the update-manager-core package, which will enable us to upgrade Ubuntu.

Now, let’s learn how to install the latest version of Ubuntu by following some steps in order.

4.1. Initiating the Version Upgrade Process

Firstly, we’ll obtain the newest version of Ubuntu that’s available on the Internet:

$ sudo do-release-upgrade -c
Checking for a new Ubuntu release
New release '23.04' available.

The do-release-upgrade command upgrades a distribution to the latest version. However, the -c option, short for –check-dist-upgrades, tells the command to only check for the newest available version of Ubuntu.

Evidently, the latest version is 23.04. So, let’s upgrade the distro to this version using the above command with no options:

$ sudo do-release-upgrade
Checking for a new Ubuntu release
Get:1 Upgrade tool signature [813 B]
Get:2 Upgrade tool [1,266 kB]
Fetched 1,267 kB in 0s (0 B/s)
authenticate 'lunar.tar.gz' against 'lunar.tar.gz.gpg’
extracting 'lunar.tar.gz’

Reading cache

Checking package manager
Reading package lists... Done
Building dependency tree
Reading state information... Done

Visibly, we’ve successfully initiated the operation.

4.2. Navigating Through the Process

During the operation, we’ll encounter some back-to-back prompts that we have to answer correctly to keep proceeding to the next step and eventually finish the upgrade process.

The first prompt asks for permission to start upgrading Ubuntu. Here, we’ll hit Enter to give permission and start the upgrade process:

Do you want to start the upgrade?

Then, we’ll see some information regarding the upgrade and a prompt that urges us to verify the information. In this case, we’ll type yes in the terminal to validate the information and proceed to the next step:

4 packages are going to be removed. 90 new packages are going to be
installed. 564 packages are going to be upgraded.

You have to download a total of 565 M. This download will take about
1 minute with a 40Mbit connection and about 15 minutes with a 5Mbit
connection.

Fetching and installing the upgrade can take several hours. Once the
download has finished, the process cannot be canceled.

 Continue [yN] Details [d] yes

The next prompt seeks permission to remove outdated packages from the distro. Here, we’ll again type yes to give permission and move on to the final step:

Searching for obsolete software
Reading state information... Done

Remove obsolete packages?


80 packages are going to be removed.

 Continue [yN] Details [d] yes

The final prompt asks us to restart the system in order to finish the upgrade process. In this case, we’ll input yes for the last time in the terminal to proceed:

System upgrade is complete.

Restart required

To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.

Continue [yN] yes

Now that we’ve finished upgrading Ubuntu, let’s see how to verify the upgrade has been successful.

5. Verify Version Upgrade

We can verify if we have the latest version of Ubuntu, i.e., 23.04, by running a single command in the terminal:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.04
Release:        23.04
Codename:       lunar

The lsb_release command prints information about the Linux Standard Base (LSB). However, the -a option, short for –all, tells the command to also display information regarding the distro, which contains its distributor ID, description, release number, and codename.

The Release label shows the release number, i.e., the current version of Ubuntu, which is 23.04 in this case. This indicates that we’ve upgraded to the latest version of Ubuntu.

6. Enable Third-Party Repositories

When we upgrade Ubuntu, all third-party repositories on the system are disabled, which can cause problems when we start operating on the upgraded Ubuntu version. So, we can enable them after the upgrade to keep the distro running smoothly.

However, this might not be the case necessarily as enabling them can cause problems too, which we can fix by simply disabling them again.

Now, let’s go through the process of enabling a disabled repo.

6.1. Finding Disabled Repos

First, we’ll find the third-party repos that are disabled on Ubuntu. To do that, we navigate to the sources.list.d directory located in /etc/apt:

$ cd /etc/apt/sources.list.d

Then, let’s list the contents of /etc/apt/sources.list.d:

$ ls -l
-rw-r--r-- 1 root root 132 May 22 04:48 ansible-ubuntu-ansible-focal.list
-rw-r--r-- 1 root root 190 May 22 04:48 google-chrome.list
-rw-r--r-- 1 root root 190 May 22 04:48 google-chrome.list.save

The -l option restricts each line to contain only a single entry.

Evidently, there are some disabled repos in the folder that we can enable one by one. Let’s see how to enable one in the next step.

6.2. Enabling a Disabled Repo

We’ll see how to enable a disabled repo by enabling the google-chrome.list repo, which provides Google Chrome on Ubuntu.

So, let’s open the repo or file in the Nano editor:

$ sudo nano google-chrome.list

Upon opening the file, we’ll see its contents in the terminal:

# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

The hash (#) symbol indicates that the line after it is commented out, making Google Chrome disabled on the distro. To enable it, we simply remove the hash:

deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

After the modification, we press Ctrl + x to quit the editor and then hit y to save the file. Upon saving, the Google Chrome repository and, thus, any future updates will be enabled.

Now, we can follow this process for every repo in the directory to enable all of them on Ubuntu.

7. Conclusion

In this article, we learned how to upgrade to the latest version of Ubuntu and also touched upon the steps that we can perform before and after the upgrade to keep the distro running smoothly.

Comments are open for 30 days after publishing a post. For any issues past this date, use the Contact form on the site.