How To Upgrade Ubuntu 18.04 to 20.04 LTS using command line

Ubuntu LTS (Focal Fossa) is the current latest stable version the Ubuntu OS. LTS stands for long-term support, which means five years, until April 2025, of free security and maintenance updates, guaranteed.

In this article we will show you an easy and fast way on how to upgrade your Virtual or Dedicated server from Ubuntu Linux 18.04 LTS or 19.10 to Ubuntu 20.04 LTS using the apt / apt-get command.

Step 1 — Make a Backup

Using Acronis Cloud Backup you can easily backup your entire Ubuntu server or choose specific files/folders which you do not wish to lose in case something goes wrong.

If you wish to use any other backup software you are free to do so, just make sure your data are placed in an offsite/off-server repository. With Acronis Backup, your data will be hosted in Acronis’ cloud datacenter and can be easily restored/recovered to a new server.

Step 2 — Upgrade all installed packages on Ubuntu 18.04 LTS

Once you have completed your existing Ubuntu server’s backup process, you can begin with the OS upgrade.

Using a root-privileges account type the following commands:

sudo apt update
sudo apt list --upgradable
sudo apt upgrade

and then type ‘Y’ to continue when prompted

Sample Outputs:

Hit:1 bionic InRelease Get:2 bionic-updates InRelease [88.7 kB] Get:3 bionic-backports InRelease [74.6 kB] Get:4 bionic-security InRelease [88.7 kB] Fetched 252 kB in 2s (113 kB/s) Reading package lists… Done Building dependency tree Reading state information… Done 53 packages can be upgraded. Run 'apt list --upgradable' to see them. Reading package lists… Done Building dependency tree Reading state information… Done Calculating upgrade… Done The following NEW packages will be installed: motd-news-config The following packages will be upgraded: base-files bcache-tools cloud-init cryptsetup cryptsetup-bin dirmngr friendly-recovery gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm gpgv initramfs-tools initramfs-tools-bin initramfs-tools-core iproute2 libaudit-common libaudit1 libc-bin libc6 libcryptsetup12 libnetplan0 libnss-systemd libpam-modules libpam-modules-bin libpam-runtime libpam-systemd libpam0g libpcap0.8 libsystemd0 libudev1 locales lshw multiarch-support nplan pollinate python3-distupgrade python3-httplib2 sosreport systemd systemd-sysv ubuntu-minimal ubuntu-release-upgrader-core ubuntu-server ubuntu-standard udev update-notifier-common 53 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 16.9 MB of archives. After this operation, 13.3 kB of additional disk space will be used. Do you want to continue? [Y/n] Y

Upon completion, reboot your server by issuing the following command:

sudo reboot

Step 3 — Remove unused old kernels from Ubuntu 18.04

Run the following command:

sudo apt --purge autoremove

Sample Outputs:

Reading package lists... Done Building dependency tree        Reading state information... Done The following packages will be REMOVED:   linux-headers-4.15.0-45* linux-headers-4.15.0-45-generic*   linux-image-4.15.0-45-generic* linux-modules-4.15.0-45-generic*   linux-modules-extra-4.15.0-45-generic* 0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded. After this operation, 334 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 138353 files and directories currently installed.) Removing linux-headers-4.15.0-45-generic (4.15.0-45.48) ... Removing linux-headers-4.15.0-45 (4.15.0-45.48) ... Removing linux-modules-extra-4.15.0-45-generic (4.15.0-45.48) ... Removing linux-image-4.15.0-45-generic (4.15.0-45.48) ...

At this point you need to install the Update Manager on server as it may or man not installed on your server.

Do so by executing the following command:

sudo apt install update-manager-core

Step 4 — Upgrade Ubuntu Linux to latest 20.04 LTS

Execute the following command:

sudo do-release-upgrade

You might notice the following message appearing after you issue the above command:

Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS develoment release
set Prompt=normal in /etc/update-manager/release-upgrades.

In that case, re-execute the command with the -d option appended in order to get the latest supported release forcefully:

sudo do-release-upgrade -d

Sample Outputs:

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
Do you want to continue?

Continue [yN] y

Starting additional sshd

To make recovery in case of failure easier, an additional sshd will
be started on port '1022'. If anything goes wrong with the running
ssh you can still connect to the additional one.
If you run a firewall, you may need to temporarily open this port. As
this is potentially dangerous it's not done automatically. You can
open the port with e.g.:
'iptables -I INPUT -p tcp --dport 1022 -j ACCEPT'

To continue please press [ENTER]

No valid mirror found warning:

Updating repository information

While scanning your repository information no mirror entry for the
upgrade was found. This can happen if you run an internal mirror or
if the mirror information is out of date.

Do you want to rewrite your 'sources.list' file anyway? If you choose
'Yes' here it will update all 'bionic' to 'focal' entries.
If you select 'No' the upgrade will cancel.

Continue [yN]

Just say Yes (y) to use the official Ubuntu repo.

You are almost done. Once prompted with the following message press ‘y’ to finish the Upgrade and get your server rebooted.

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] y
Connection to closed by remote host.
Connection to closed.

Step 5 — Ubuntu OS Upgrade Verification

Check your Distro version by running the following command:

lsb_release -a

Sample outputs:

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal

Verify Linux kernel version and other log files too:

tail -f /var/log/my-app.log
uname -mrs

Sample outputs:

Linux 5.4.0-24-generic x86_64

Congrats! Your Ubuntu server has now been successfully upgraded to Ubuntu 20.0.4 LTS!

Not comfortable with Linux Systems administration? Let us do it for you!

NetShop ISP’s experienced Linux system admins can help you with full server management, whether it’s a virtual or a dedicated server. From Operating System installations, troubleshooting and OS distro upgrades, we can take care the whole aspect of your linux machine’s administration.

Browse our VPS Plans and Dedicated Servers to find the server that satisfies your needs and budgets and get started!




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store