How to upgrade Ubuntu from the command line
Ubuntu's update manager makes it easier to upgrade the installation to the main release. The utility's graphical interface guides users to upgrade step-by-step, making it easier to follow and implement.
However, sometimes you cannot use the graphical utility on the server because there is no access to the graphical interface. In this case you must use the command line to upgrade Ubuntu.
- Instructions for managing programs in Ubuntu via the command line
- How to enable automatic system update mode on Ubuntu
- Simple way to update Ubuntu ISO file
Do-release-upgrade command with -d switch
The Ubuntu upgrade utility from the old version to the new version is called do-release-upgrade. This is a script written in Python programming language.
Typically, this script will upgrade from a stable release (or LTS - Long-term Support) to the next release. For example, it can update Ubuntu 16.04 to Ubuntu 18.04. However, when a new LTS version appears, you cannot upgrade it until the first point release is released. For example, if you are using version 16.04.5, you cannot upgrade to version 18.04 but wait until version 18.04.1 is released. The first new LTS release still has bugs, but if you really need the new LTS, you can use the command line switch to force the utility to update. So when you just released version 18.04 you can update it with the following command:
sudo do-release-upgrade -d
How to upgrade Ubuntu with the do-release-upgrade command
Before upgrading, you should temporarily disable a third-party repository (PPA) or entries you have added /etc/apt/sources.list and /etc/apt/sources.list.d/ . If you don't add any software repositories other than the repositories provided by Ubuntu, you can skip this step.
Some packages from these software repositories may affect new packages from the next Ubuntu release. Therefore you should run sudo apt update to refresh package information. Then, use commands like sudo apt autoremove nginx to delete the programs you have installed from third-party providers.
If there is no do-release-upgrade command on your system, install it with the following command:
sudo apt install update-manager-core
Usually it is installed by default. You need to update the software package before upgrading to a new version of Ubuntu. To update all packages on the system, run the following command:
sudo apt update && apt upgrade sudo
Update to Ubuntu for short-term support (Optional)
Even numbers, such as 18.04, are used for long-term support releases (LTS). odd numbers such as 19.04 are used for short-term releases. If the version you are using is long-term and wants to upgrade to the next long-term version, skip this step. If you are using a long-term version such as 18.04 and want to upgrade to version 18.10 or 19.04 (any subsequent versions available), edit this file:
sudo nano / etc / update-manager / release-upgrades
Change Prompt = lts to Prompt = normal , press Ctrl + X , then type y and press Enter to save the file.
Upgrade local computer
Although you can open terminal emulator software on a graphical computer, there is a problem. When the graphics server is upgraded, it can restart, causing the terminal session to be lost. So you should log out of that graphics session, then press Alt + Ctrl + F2 or Alt + Ctrl + F3 and log in to the TTY control panel before starting to use the upgrade script below.
Upgrade Ubuntu
Run the following upgrade script:
sudo do-release-upgrade
Now carefully follow the instructions on the screen. This tutorial will be slightly different depending on your upgrade script. For example, when connecting to an SSH session, you need to take one more step like the image below.
The next step, you need to handle the configuration file changes in the new package version.
If you have changed the configuration file mentioned, you can press N to keep the changes. If the server provider changes those files, press N. In case you and the provider do not make any changes, type Y to get the updated configuration file.
The upgrade process is not complicated, but there may be some problems depending on the level of 'clean' on your system (no third-party software repositories). After the update utility is complete, you need to restart the computer. Usually this script will provide options to reboot, otherwise you can run:
sudo systemctl reboot
Or more simply with the command:
sudo reboot
If there are no upgrade errors with the new software, everything will work when the machine restarts. If an error occurs, refer to the article How to fix Ubuntu update errors
I wish you all success!
You should read it
- Ubuntu Server Upgrade Steps
- How to Upgrade Ubuntu
- 5 things to do after upgrading to Ubuntu 22.04 LTS
- What's New in Ubuntu 21.10?
- Steps to upgrade Ubuntu operating system to the new Version
- 5 reasons to upgrade to Ubuntu 19.04 'Disco Dingo'
- Everything you need to know about using Nala on Ubuntu
- Ubuntu 19.10: Roadmap for release & planned features
May be interested
- Forget the GUI, the Command Line is returningmanaging windows to the cloud also means a command line revival with powershell and bash.
- How to create and run a shell script in Ubuntu 20.04 LTSshell is the command interpreter written by the user. script shell helps users write and execute multiple commands at the same time. in this article, you will learn how to execute shell scripts through command line input.
- How to Install Ubuntu Packagesthis wikihow will show you how to install packages on ubuntu using the ubuntu software center, the synaptic package manager, and a command-line window. the ubuntu software center is similar to the app store for macos and the microsoft...
- Canonical Urges Ubuntu 20.04 LTS Users to Upgrade or Purchase Extended Supportas a long-term support release, ubuntu 20.04 lts (long-term support) will be supported with continuous updates for a total of 5 years, meaning it will reach end-of-life around april 2025.
- 5 reasons to upgrade to Ubuntu 19.04 'Disco Dingo'some new additions in ubuntu 19.04 'disco dingo' show that developers have spent more time working directly on gnome.
- Ubuntu 21.04 users need to update the system ASAPaccording to the proposed roadmap, it is only a few days before canonical will officially stop providing updates for ubuntu 21.04 'hirsute hippo', which has been available since april last year.
- 5 reasons why people love the Linux command linemany people are afraid of the command line. they see it as something for software developers or geeks. but the command line is merely another way of interacting with a pc, and there are some tasks that are very easy to do with the cli.
- 5 best command line emulation software for Windows 10currently, users can get a shell within windows 10, but many still prefer the more configurable command line emulator applications. so this article will introduce you to five of the best command line emulation software for windows 10.
- How to check internet speed with the command line in Linuxtoday, tipsmake.com will read how to check the speed of the internet from the command line via terminal in various popular linux distributions, including ubuntu, fedora and arch linux.
- How to upgrade to Fedora 32if you are upgrading to fedora 32, there are several ways to do so. in this article, readers will learn how to upgrade with the graphics tools available through gnome software and the command line with dnf plugin, dnf-plugin-system-upgrade.