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
- 7 reasons to upgrade to Ubuntu 23.04
- Ubuntu 21.04 users need to update the system ASAP
- 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
- What's new in Ubuntu 18.04 LTS just released?
- How to Upgrade VLC in Ubuntu
Maybe you are interested
6 signs it's time to upgrade your Smart TV
Why upgrade from Mac mini M1 to Mac mini M4?
Canonical Urges Ubuntu 20.04 LTS Users to Upgrade or Purchase Extended Support
Instructions for using Flyby11 to upgrade to Windows 11 24H2
Kali Linux 2022.3: Comes with white hat hacker tool upgrades
The Latest Features in Meta Llama AI's Major Upgrade