Categories: Ubuntu

Upgrade Ubuntu From Command Line

“Ubuntu releases periodical updates, and the current version you are using is likely not the latest release. Most systems retain the Ubuntu version installed when it got booted, but it’s advisable to upgrade Ubuntu to get the latest fixes for bugs and new tools.

That said, if you are looking for the quickest way to upgrade Ubuntu, the command line is the solution. We will cover upgrading Ubuntu via the command line.”

Upgrading Ubuntu Via Command Line

There are two ways to upgrade Ubuntu. You can choose to install the latest version, which deletes all your data and files. Alternatively, you can upgrade from the terminal without installing Ubuntu afresh, which we will do in this article.

Key
Sponsored
Points Before Upgrading

Before we upgrade Ubuntu, there are a few considerations to note.

  • You must have sudo privileges to initiate the upgrade
  • Your root partition should have 3 – 4 GB of free space.
  • You require a strong internet connection.
  • Create a backup of your data by creating a complete system snapshot.
  • There is no means of downgrading your Ubuntu

How to Upgrade Ubuntu to Latest Version

With Ubuntu, you can upgrade the whole version or the installed packages.

To only upgrade the packages, use the commands below.

$ sudo apt-get update && sudo apt-get upgrade

To upgrade the whole version, start by checking the current Ubuntu version you are running.

$ lsb_release -a

For this case, we are running Ubuntu 20.04.4. The current release when writing this article is Ubuntu 22.04. Follow the steps below to Upgrade Ubuntu. The first upgrade will get version 21.10, but you can again upgrade it to 22.04.

Step 1. Install the Update Manager Core Package

Open your terminal and enter the command below.

$ sudo apt install update-manager-core

For the upgrade to work, ensure the upgrade policy is set to “Prompt=Its” or “Prompt=normal” in the /etc/update-manager/release-upgrades file.

Note that this guide assumes you are upgrading your desktop Ubuntu version. However, if you are working remotely over ssh, you will need to temporarily open port 1022 for the upgrade to work, especially if you are running a firewall.

$ sudo iptables -I INPUT -p tcp –dport 1022 -j ACCEPT

Step 2: Install Pending Package Updates

It’s a good habit to install any pending software updates before upgrading the whole system.

Sponsored
$ sudo apt update && sudo apt dist-upgrade

Reboot your system before proceeding to upgrade.

Step 3: Start the Upgrade

With a stable connection to save time, run the command below to download the needed files and upgrade your Ubuntu to the latest version. The download size is around 1.8 GB. Therefore, your internet speed determines how fast it takes.

$ sudo do-release-upgrade

When prompted whether to install the downloaded packages, confirm to upgrade the system.

Once the upgrade completes, choose to restart the machine to finish the upgrade. Click the y keyboard key and press the enter key.

You can verify the upgrade by checking the current version, as shown.

Our current upgraded version is 21.10. However, if you run the upgrade command again, it will upgrade to the latest version. The upgrading process is simple. The only thing you should have is enough time to let the process complete and a stable internet connection. Furthermore, any prompts during the process are clear, and you will be required to select an option to proceed. Therefore, ensure to create a backup to roll back to in case something messes along the way. If you follow the procedure listed in this guide, you shouldn’t have any trouble.

Conclusion

You now know how to upgrade Ubuntu to the latest version from the command line. Staying updated is recommended as new releases offer better tools. However, always create a backup of your data and note that you can’t degrade Ubuntu unless via a fresh install. Enjoy the new Ubuntu upgrade!

Ubuntu Server Admin

Recent Posts

Building optimized LLM chatbots with Canonical and NVIDIA

The landscape of generative AI is rapidly evolving, and building robust, scalable large language model…

55 minutes ago

Unlocking Edge AI: a collaborative reference architecture with NVIDIA

The world of edge AI is rapidly transforming how devices and data centers work together.…

55 minutes ago

How to Install and Use Zig Programming Language on Ubuntu or Debian Linux

In this article, we will see how to install and use zig programming language on…

4 hours ago

Linux Sed Tutorial: Learn Text Editing with Syntax and Examples

This article was adapted from its original version on NixCraft. Sed is an acronym for…

10 hours ago

How to Fix VMware’s “Could not open /dev/vmmon” Error on Ubuntu

You’ve recently installed VMware Workstation on your Ubuntu system and encountered the frustrating “Could not…

18 hours ago

How to Fix Ubuntu 404 Errors While Fetching Dependencies

Have you ever found yourself staring at a terminal full of 404 errors while trying…

18 hours ago