How to upgrade Ubuntu using command line

Although the Ubuntu team have made a great job of making the update process for the distribution really user friendly with a nice graphical user interface, one of the most Frequently Asked Questions (FAQ) relates to upgrading Ubuntu Distribution using the terminal window.

How To upgrade ubuntu using command line.

To open your Terminal Window, click on your ubuntu icon and type in terminal in the text box provided, or you can simply use the keyboard short cut of Ctrl + Alt + T

terminal

We’ll be making use of the APT package handling Utility to preform these updates. The apt-get is the command-line tool for handling packages, and may be considered the user’s “back-end” to other tools using the APT library.

apt-get1

The first command I advise you to run using apt-get, will give you access to the all important manual. This will provide you with all the important details about the commands we will be running. Using your terminal window type in the following and hit Enter.

Shell

Have a quick read through this manual just to get acquainted with the commands, you will find that they will come in very handy the more you get familiar with linux. We will provide some text from manual below the commands to help you understand what you are doing.

How To upgrade ubuntu distribution using command line.

Always preform some updates to your current release.

Shell

update is used to synchronise the package index files from their sources. The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list.

An update should always be performed before an upgrade or dist-upgrade.

Install the newest packages

Shell

upgrade is used to install the newest versions of all packages currently installed on the system from the sources enumerated in /etc/apt/sources.list.

Packages currently installed with new versions available are retrieved and upgraded; under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. New versions of currently installed packages that cannot be upgraded without changing the install status of another package will be left at


their current version. An update must be performed first so that apt-get knows that new versions of packages are available.

Upgrade your distribution packages

Shell

dist-upgrade in addition to performing the function of upgrade, also intelligently handles changing dependencies with new versions of packages; apt-get has a “smart” conflict resolution system, and it will attempt to upgrade the most important packages at the expense of less important ones if necessary.

The dist-upgrade command may therefore remove some packages.

The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files. See also apt_preferences(5) for a mechanism for overriding the general settings for individual packages.

full-upgrade  is the same as dist-upgrade so we can use both command interchangeable.

Preform the upgrade

Shell
Shell

do-release-upgrade upgrades operating system to latest release command-line. This is the preferred command if the machine has no graphic environment or if the machine is to be upgraded over a remote connection.

There may be some additional screen prompts for input. but generally these are only confirmations that you want to carry out the actions.

As an additional precaution I always prefer runs steps 1,2,3 after the install has completed and I have restarted the machine.

Advice

When upgrading LTS to LTS you may need to do the initial upgrade to x.10 release then do an additional upgrade to the X.04 release.

Gary Woodfine

Technical Director at Denizon
Gary is Technical Director at Denizon, an independent software vendor specialising in IoT, Field Service and associated managed services,enabling customers to be efficient, productive, secure and scalable in a way which helps them address and reduce their ecological impact.

Denizon's product line successfully integrate IoT, Artificial Intelligence and Blockchain technology to enable efficient, productive, secure and scalable solutions to help organisations address increasing energy demands, ecological impact and Health & Safety concerns of their staff.

Latest posts by Gary Woodfine (see all)