Jump to content

Upgrade Ubuntu 20.04 to 22.04 via the Command Line


Linux Hint

Recommended Posts

This post covers all the steps to upgrade Ubuntu 20.04 to 22.04. When you have Ubuntu 20.04, you miss out on the new features and the benefits offered with Ubuntu 22.04. Besides, staying updated is recommended to enjoy the security fixes that the newer Ubuntu versions offer. Ubuntu 22.04 comes with the codename “Jammy Jellyfish”. By the end of this post, you will learn what it takes to get the recent LTS version. Let’s begin!

How to Upgrade Ubuntu 20.04 to 22.04 via the Command Line

Mastering the command line gives you superiority. Although updating Ubuntu via GUI is possible, our focus will be via the command line.

First, let’s check the current Ubuntu version that we are running using the following command:

$ lsb_release -a

For this case, we confirmed that we currently have Ubuntu 20.04 with the codename, “focal”.

word-image-179477-1.png

Before upgrading your Ubuntu, it’s wise to back up your system. Whenever possible, take a snapshot of the entire system so that if anything happens, you can revert it without losing your data. There are different tools and commands that you can use to create the backup. Once you created the backup, proceed as follows:

Step 1: Update and Upgrade

You should update the current Ubuntu version to ensure all that packages are up-to-date before you can initiate the upgrade. A simple “update” command is all you need.

$ sudo apt update

word-image-179477-2.png

After updating the packages, run the “upgrade” command to ensure that all packages get upgraded for a clean transition.

$ sudo apt upgrade

word-image-179477-3.png

Lastly, run the following command to check and cater for all package dependencies:

$ sudo apt dist-upgrade

word-image-179477-4.png

Step 2: Reboot the System

After updating and upgrading your Ubuntu repositories, some packages may no longer be required. You can optionally remove them with the “autoremove” command. You must then reboot your system to ensure that all changes take effect before we upgrade to Ubuntu 22.04. Use the following commands:

$ sudo apt autoremove

$ sudo reboot

word-image-179477-5.png

Step 3: Upgrade to Ubuntu 22.04

A quick way to upgrade Ubuntu is using the “do-release-upgrade” command. Once executed, it will check for new Ubuntu releases, update the “sources.list”, and initiate the upgrade.

$ sudo do-release-upgrade

Notice how, after we ran the previous command, Ubuntu identifies “Jammy” as the new release which is the codename for Ubuntu 22.04. It then proceeds to prepare for the upgrade.

word-image-179477-6.png

Once all preparations including updating the “sources.list” are made, you will get prompted to confirm whether to proceed with the upgrade. You can type “d” to view the upgrade details or start the upgrade by pressing “y” as shown in the following image:

word-image-179477-7.png

When you get prompted to confirm to upgrade Firefox, hit the “Enter” key on your keyboard, and the upgrade will continue. For any prompt that appears, check its details and select the ideal action that suits you.

word-image-179477-8.png

You will also get prompted to remove the obsolete packages before the upgrade completes. You can choose to stick with the packages and remove them later or confirm the action and get all the packages removed to retain only those that come with Ubuntu 22.04.

word-image-179477-9.png

The last step is to reboot the system and boot to the new Ubuntu 22.04. Press “y” when you get the following prompt and wait for your system to reboot.

word-image-179477-10.png

After the restart, open your terminal and check the Ubuntu version that runs on it. You will see that the codename and LTS version have changed. That’s it! You managed to upgrade your Ubuntu 20.04 to 22.04 successfully.

$ lsb_release -a

word-image-179477-11.png

Optionally, you can run the “update” and “upgrade” commands to ensure that all packages are updated and your system is ready for use.

$ sudo apt update && sudo apt upgrade

word-image-179477-12.png

Conclusion

Upgrading your Ubuntu is recommended to stay updated with the latest security fixes and updates. With the simple steps that are covered in this post, you can upgrade from Ubuntu 20.04 to Ubuntu 22.04. Hopefully, you now understand what it takes to upgrade your Ubuntu.

View the full article

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...