Upgrade Ubuntu 18.04 to 20.04 LTS using command line

I need to upgrade the Ubuntu Linux version 18.04 LTS server to a 20.04 LTS server using the command line option. How do I upgrade Ubuntu 18.04 to 20.04?

LTS is an abbreviation for “Long Term Support.” A new LTS version is released every two years and gets five years on five years of support and patches. The latest version of Ubuntu is 20.04 LTS, and codenamed as Focal Fossa. Ubuntu 20.04 released on April 23, 2020. This page shows you how to upgrade the existing version of Ubuntu Linux 18.04 LTS or 19.10 to Ubuntu 20.04 LTS from the apt command/apt-get command.
Tutorial requirements
Operating system/appUbuntu Linux
Root privileges requiredYes
DifficultyEasy (rss)
Estimated completion time15m (depends upon internet speed)
Table of contents


Procedure to upgrade Ubuntu 18.04 to 20.04

  1. Create a backup of your server or vm.
  2. Upgrade all installed packages of Ubuntu version 18.04 by running sudo apt update && sudo apt upgrade command.
  3. Reboot the Ubuntu Linux system by tying the sudo reboot command
  4. Install the Ubuntu update tool, run: sudo apt install update-manager-core
  5. Start the upgrade procdure, run: sudo do-release-upgrade
  6. Reboot the box, run: sudo reboot
  7. Verify upgrades

Let us see all commands and examples.

NOTE: You can upgrade to Ubuntu 20.04 LTS from either Ubuntu 18.04 LTS or Ubuntu 19.10 only

Step 1. Make a backup

I cannot be stressed enough how important it is to make a backup of your server before you do this. Note down the Ubuntu Linux version
lsb_release -a

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.4 LTS
Release:	18.04
Codename:	bionic

Find and note down the Linux kernel version too, run:
uname -mrs
Sample outputs:

Linux 4.15.0-96-generic x86_64

On AWS you might see the latest Linux kernel version for Ubuntu 18.04 LTS:

Linux 5.3.0-1019-aws x86_64

Step 2. Upgrade all installed packages on Ubuntu 18.04 LTS

Now, that you have backup, type the following apt command to upgrade the installed packages of Ubuntu version 18.04 LTS:
sudo apt update
sudo apt list --upgradable
sudo apt upgrade

Upgrade installed packages of Ubuntu version 18.04 LTS
You must reboot when Ubuntu Linux kernel and libs gets updated:
sudo reboot
See “Ubuntu 18.04 update installed packages for security” for more info.

Step 3. Ubuntu 18.04 remove all unused old kernels

Run the following to remove them:
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*
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) ...

Make sure you install update-manager-core package

We need to install the Update Manager on server as it may or man not installed on your box:
sudo apt install update-manager-core

Step 4. Upgrade Ubuntu Linux to latest LTS

Execute the following command:
sudo do-release-upgrade
Please note if you may be greeted with the following message:

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, pass the -d option 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 to use the official Ubuntu repo.

Reboot the box

We are almost done:

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 52.xxx.yy.zz closed by remote host.
Connection to 52.xxx.yy.zz closed.

In other words, confirm by typing ‘y‘ when asked to reboot the box:
Upgrade Ubuntu 18.04 to 20.04 completed and restart the system

Step 5. Verification

Check your Disro version:
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

On AWS EC2 or Lightsail server will see the following Linux kernel:

Linux 5.4.0-1011-aws x86_64

Step 6. Enable disabled 3rd party repo

During the upgrade process, 3rd party software repos will be disabled for stability reasons. For example, Google Chrome and others are disabled. So we need to enable those using either the CLI or GUI tool called Software and Updates. Use the cd command as follows:
cd /etc/apt/sources.list.d/
List those repos:
ls -l
Let us see google-chrome.list using the cat command:
cat google-chrome.list
Sample outputs:

# You may comment out this entry, but any other modifications may be lost.
# deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main # disabled on upgrade to focal

Edit the file:
sudo nano google-chrome.list
## OR ##
sudo vim google-chrome.list

Now update the file by removing the ‘#’ so that it reads as follows:

# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main # disabled on upgrade to focal

Save and close the file in vim text editor. Finally update your apt repos:
sudo apt update
sudo apt upgrade

Step 7. Upgrade Ubuntu To 20.04 LTS Focal Fossa desktop system using GUI method

Let us see how to upgrade on a desktop system.

  • First, keep backups of all important data.
  • Open the “Software & Updates” Setting in System Settings.
  • Select the 3rd Tab called “Updates“.
    step -1

    Click to enlarge

  • Set the “Notify me of a new Ubuntu version” drop down menu to “For long-term support versions” if you are using 18.04 LTS; set it to “For any new version” if you are using 19.10.
  • Open the terminal and type the following command:
    update-manager -c -d
    step -2
  • Next, update Manager should open up and tell you that Ubuntu 20.04 LTS is now available. If the update-manager -c -d command failed to work, run the following command:
  • Click Upgrade and follow the on-screen instructions.

Ubuntu do-release-upgrade command-line options

-hDisplay help message and exit.
-VShow version and exit.
-dIf using the latest supported release, upgrade to the development release.
--data-dir=DATA_DIRDirectory that contains the data files
-pTry upgrading to the latest release using the upgrader from $distro-proposed
-m MODERun in a special upgrade mode. Currently ‘desktop’ for regular upgrades of a desktop system and ‘server’ for server systems are supported.
-f FRONTENDRun the specified frontend. You can use “DistUpgradeViewText”, “DistUpgradeViewGtk”, and “DistUpgradeViewKDE” FRONTEND.
-cCheck only if a new distribution release is available and report the result via the exit code.
--allow-third-partyTry the upgrade with third party mirrors and repositories enabled instead of commenting them out.
-qWork quietly.


You did it. Upgrade to Ubuntu 20.04 LTS was successful. Now you can test your apps and code that is compatible with the Ubuntu Linux 20.04 LTS server. See LTS page for all details.

This entry is 5 of 5 in the Upgrade On a Ubuntu Server Tutorial series. Keep reading the rest of the series:
  1. How to upgrade Ubuntu 16.04 to 18.04 LTS using terminal
  2. AWS Lightsail upgrade Ubuntu 16.04 LTS to 18.04 LTS
  3. How Do I Update Ubuntu Linux Softwares Using Command Line?
  4. HowTo: Upgrade To a Newer Version of Ubuntu 14.04 LTS
  5. Upgrade Ubuntu 18.04 to 20.04 LTS using command line
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

11 comments… add one
  • Jiří Aug 5, 2020 @ 8:52


    I am having a problem with the last command(/usr/lib/ubuntu-release-upgrader/check-new-release-gtk) because after running this command, terminal wrote out:

    /usr/lib/ubuntu-release-upgrader/check-new-release-gtk:30: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
      from gi.repository import Gtk

    I´ll be glad for any help. Thanks in advance :D

  • Chris Smith Aug 11, 2020 @ 18:49

    Upgraded my web-server. Thank you for this article.

  • Dootta Aug 14, 2020 @ 17:15

    I’m a little confused about Step 6 and what will happen to all the binaries I’ve installed from bionic repos.

    Am I likely to have a lot of incompatibility issues with programs installed from third party repos like wine, lutris, vmware, virtualbox or even manually via .deb files? What about snap installations?

    For example, if I ran this command
    sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'

    do I need to do something after the upgrade to specify `focal` and trigger to reinstall the binaries?

    Thanks in advance!

    • 🐧 Vivek Gite Aug 15, 2020 @ 8:14


      a) All of your third party will be disabled and won’t work. You need to enable them one by one as

      b) snap package will be updated automatically

      c) You need to reinstall those binaries as those might not work.

      As usual keep all backup before doing anything else. Good luck!

      • Dootta Aug 16, 2020 @ 13:27

        Thank you very much for your comments and the guide. This is the most comprehensive guide I’ve found so far, I think most of the upgrade guides are far too simplistic.

        I finally took the plunge last night after backing up with Clonezilla. I’m now mostly back up and running except for a few things.

        It might be worth updating the guide to advise `sudo apt full-upgrade` since I needed to do this. Some LibreOffice packages had been held back and the upgrade won’t proceed unless everything is updated.

        During the upgrade I was faced with having to decide whether to keep 4 or 5 config files or install package maintainers version. I found the compare output hard to interpret but eventually worked out lines that are preceded with a minus sign are additional lines I have as compared to the base version, and lines preceded with a plus are lines that I’m in fact missing from my version of the config file.

        Post upgrade the hardest thing to get working again was wine, it refused to install following the official instructions from winehq. Eventually I got it to install following instructions from another site, but that created a mess with the package sources (duplicate sources). Thanks to your guide I knew how to fix it.

        • 🐧 Vivek Gite Aug 16, 2020 @ 15:57

          Glad everything went smoothly.

          Typically it is not needed to run sudo apt full-upgrade but you got tons of 3rd party apps or repo. Otherwise do-release-upgrade -d is more than sufficient.

  • Bathinda Helper Aug 30, 2020 @ 12:23

    The best article written on this topic so far (I’ve ready nearly 12 other articles on the same subject).

  • Kristie Sep 4, 2020 @ 1:24

    My preference for step 4 is to replace with:

    sudo do-release-upgrade -d -f DistUpgradeViewGtk3

    This way you get a more holistic progression of your download.

  • JR Sep 4, 2020 @ 7:40

    Unfortunately doesnt worked for me. Got the Error

    "authenticate 'focal.tar.gz' against 'focal.tar.gz.gpg' 
    Authentication failed
    Authenticating the upgrade failed. There may be a problem with the network or with the server."

    And im stucked there. Tips that suggested reinstalling the keyring also didnt resolved the issue.

    • 🐧 Vivek Gite Sep 4, 2020 @ 8:33

      Backup all data and everything as usual. Next,
      sudo apt install --reinstall ubuntu-keyring
      Edit the /etc/apt/sources.list manually. Sample file:

      deb http://archive.ubuntu.com/ubuntu/ focal main restricted
      deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
      deb http://archive.ubuntu.com/ubuntu/ focal universe
      deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
      deb http://archive.ubuntu.com/ubuntu/ focal multiverse
      deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
      deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
      deb http://security.ubuntu.com/ubuntu focal-security main restricted
      deb http://security.ubuntu.com/ubuntu focal-security universe
      deb http://security.ubuntu.com/ubuntu focal-security multiverse

      Finally try:
      sudo apt update
      sudo apt install --reinstall ubuntu-keyring

      Now start install procedure from step # 4:
      sudo apt install update-manager-core
      sudo do-release-upgrade

      If failed means something is wrong with existing files.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.