- How to upgrade
- Upgrade paths
- Upgrade checklist
- Upgrade
- do-release-upgrade
- Pre-upgrade summary
- Configuration changes
- Package removal
- Reboot
- How to Update Ubuntu Linux [Beginner’s Tip]
- Method 1: Update Ubuntu via the Command Line
- Explanation: sudo apt update
- Explanation: sudo apt upgrade
- Method 2: Update Ubuntu via the GUI [For Desktop Users]
- A few things to keep in mind about updating Ubuntu
- Cleaning up after an update
- Live patching the kernel in Ubuntu Server to avoid rebooting
- Ubuntu version upgrades are different from package upgrades
- Conclusion
How to upgrade
This article details how to upgrade an Ubuntu Server or Ubuntu cloud image to the next release.
Upgrade paths
Ubuntu supports the ability to upgrade from one LTS to the next LTS in sequential order. For example, a user on Ubuntu 16.04 LTS can upgrade to Ubuntu 18.04 LTS, but cannot jump directly to Ubuntu 20.04 LTS. To do this, the user would need to upgrade twice: once to Ubuntu 18.04 LTS, and then upgrade again to Ubuntu 20.04 LTS.
It is recommended that users run an LTS release as it provides 5 years of standard support and security updates. After the initial standard support, an extended support period is available via an Ubuntu Pro subscription.
For a complete list of releases and current support status see the Ubuntu Wiki Releases page.
Upgrade checklist
To ensure a successful upgrade, please review the following items:
- Check the release notes for the new release for any known issues or important changes. Release notes for each release are found on the Ubuntu Wiki Releases page.
- Fully update the system. The upgrade process works best when the current system has all the latest updates installed. Users should confirm that these commands complete successfully and that no further updates are available. It is also suggested that users reboot the system after all the updates are applied to verify they are running the latest kernel. To upgrade run the following commands:
sudo apt update sudo apt upgrade
Upgrade
It is recommended to upgrade the system using the do-release-upgrade command on Server edition and cloud images. This command can handle system configuration changes that are sometimes needed between releases.
do-release-upgrade
To begin the process run the following command:
Upgrading to a development release of Ubuntu is available using the -d flag. However, using the development release (or this flag) is not recommended for production environments.
Upgrades from one LTS to the next LTS release are only available after the first point release. For example, Ubuntu 18.04 LTS will only upgrade to Ubuntu 20.04 LTS after the 20.04.1 point release. If users wish to update before the point release (e.g., on a subset of machines to evaluate the LTS upgrade) users can force the upgrade via the -d flag.
Pre-upgrade summary
Before making any changes the command will first do some checks to verify the system is ready to update. The user will be prompted with a summary of the upgrade before proceeding. If the user accepts the changes, the process will begin to update the system’s packages:
Do you want to start the upgrade? 5 installed packages are no longer supported by Canonical. You can still get support from the community. 4 packages are going to be removed. 117 new packages are going to be installed. 424 packages are going to be upgraded. You have to download a total of 262 M. This download will take about 33 minutes with a 1Mbit DSL connection and about 10 hours with a 56k modem. Fetching and installing the upgrade can take several hours. Once the download has finished, the process cannot be canceled. Continue [yN] Details [d]
Configuration changes
It is possible during the upgrade process the user gets presented with a message to make decisions about package updates. These prompts occur when there are existing configuration files edited by the user and the new package configuration file are different. Below is an example prompt:
Configuration file '/etc/ssh/ssh_config' ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version. What would you like to do about it ? Your options are: Y or I : install the package maintainer's version N or O : keep your currently-installed version D : show the differences between the versions Z : start a shell to examine the situation The default action is to keep your current version. *** ssh_config (Y/I/N/O/D/Z) [default=N] ?
Users should look at the differences between the files and decide what to do. The default response is to keep the current version of the file. There are situations where accepting the new version, like with /boot/grub/menu.lst , is required for the system to boot correctly with the new kernel.
Package removal
After all packages are updated the user will again remove any obsolete, no longer needed, packages:
Remove obsolete packages? 30 packages are going to be removed. Continue [yN] Details [d]
Reboot
Finally, when the upgrade is complete the user is prompted to reboot the system. The system is not considered upgraded until a reboot occurs:
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]
How to Update Ubuntu Linux [Beginner’s Tip]
This tutorial shows you how to update Ubuntu for both server and desktop versions. Also learn the difference between update and upgrade.
Let me give you more details. Please note that this tutorial is valid for Ubuntu 20.04, 22.04, or any other version. The command line method is also valid for Ubuntu-based Linux distributions, like Linux Mint, Linux Lite, elementary OS, etc.
One more thing. This article is about keeping your Ubuntu system updated. If you are looking for upgrading from one release to another, please check my tutorial on upgrading Ubuntu version.
Method 1: Update Ubuntu via the Command Line
First, open the terminal in Ubuntu desktop. You can find it in the menu, or use the Ctrl+Alt+T keyboard shortcut. If you are logged on to an Ubuntu server, you already have access to a terminal.
In the terminal, you just have to use the following command:
sudo apt update && sudo apt upgrade -y
It will ask for a password. You can use your account’s password. You won’t see characters on the screen while typing password in the terminal, so keep on typing your password and hit enter. This will update the packages in Ubuntu.
See, how easy it is to update Ubuntu from terminal? Now let me explain the above command.
It’s actually not a single command, it’s a combination of two commands. The && is a way to run multiple commands in Linux in a way such that the second command runs only when the previous command ran successfully.
The “-y” in the end automatically enters “yes” when the command “apt upgrade” ask for your confirmation before installing updates.
Note that you can also use the two commands separately, one by one:
sudo apt update sudo apt upgrade
It will take a little longer because you have to wait for one command to finish and then enter the second command.
More than just OS updates: Unlike Windows, Linux works with a package manager. When you run the updates, it updates all the packages installed via apt. This means updating Ubuntu will update the core operating system, Linux kernels as well as the applications installed from the software center (if they were apt packages) or installed using apt command.
Explanation: sudo apt update
This command updates the local database of available packages. If you don’t run this command, the local database won’t be updated and your system will not know if there are any new versions of packages available.
This is why, when you run the “sudo apt update” command, you’ll see lots of URLs in the output. The command fetches the package information from the respective repositories (the URLs you see in the output).
At the end of the command, it tells you how many packages can be upgraded. You can see these packages by running the following command:
Explanation: sudo apt upgrade
This command matches the versions of installed packages with the local database. It collects all of them, and then it will list those packages that have a newer version available. At this point, it will ask if you want to upgrade the installed packages to the newer version.
You can type “yes,” or “y,” or just press enter to confirm the installation of updates.
So the bottom line is that “sudo apt update” checks for the availability of new package versions, while “sudo apt upgrade” actually installs the new versions.
The term update might be confusing, as you might expect the “apt update” command to update the system by installing new software, but that’s not how it works.
Method 2: Update Ubuntu via the GUI [For Desktop Users]
If you are using Ubuntu as a desktop, you don’t have to go to the terminal to update the system. You can still use the command line, but it’s optional for you.
In the menu, look for “Software Updater” and run it.
It will check if there are updates available for your system.
If there are updates available, it will give you the option to install the updates.
Click on “Install Now.” It may ask for your password.
Once you enter your password, it will start installing the updates.
In some cases, you may need to reboot your Ubuntu system for the installed updates to work properly. You’ll be notified at the end of the update if you need to restart the system.
You can choose to restart later if you don’t want to reboot your system straightaway.
Tip: If the software updater returns an error, you should use the command “sudo apt update” in the terminal. The last few lines of the output will contain the actual error message. You can then search on the internet for that error and fix the problem.
A few things to keep in mind about updating Ubuntu
You just learned how to update your Ubuntu system. If you are interested, you should also know these few things relating to Ubuntu updates.
Cleaning up after an update
After an update, your system may have some unnecessary packages that are no longer required. You can remove such packages and free up some space by using this command:
Live patching the kernel in Ubuntu Server to avoid rebooting
In the case of Linux kernel updates, you’ll have to restart the system after the update. This can be a problem if you don’t want downtime for your server.
The live patching feature allows for the patching of the Linux kernel while it is still running. In other words, you don’t have to reboot your system.
If you manage servers, you may want to enable live patching in Ubuntu.
Ubuntu version upgrades are different from package upgrades
The update methods discussed here keep your Ubuntu install fresh and updated. It doesn’t cover OS version upgrades (for example, upgrading Ubuntu 16.04 to 18.04).
Ubuntu version upgrades are an entirely different thing. They involve updating the entire operating system core. You’ll need to make proper backups before starting this lengthy process.
Conclusion
I hope you liked this tutorial on updating the Ubuntu system, and that you learned a few new things.
If you have any questions, please fee free to ask. If you are an experienced Linux user and have some tip that can make this tutorial more useful, please share it with the rest of us.