How Do I Update Ubuntu Linux Software Using Command Line 2022


have latest version of Ubuntu Linux LTS server. How do I update Ubuntu Linux for security and application fix/upgrades using ssh command line? How can I install updates via command line option?

Ubuntu Linux can be upgraded using GUI tools or using traditional command line tools such as:

  1. apt-get or apt commandapt-get command or apt command is the command-line tool for handling packages for Ubuntu machine.
  2. aptitude command – aptitude is a text-based interface to the Debian GNU/Linux package system including Ubuntu Linux.
Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Linux terminal
Category Package Manager
Prerequisites Ubuntu Linux 18.04/20.04/22.04 LTS+
OS compatibility Pop!_OS Debian Mint Ubuntu
Est. reading time 5 minutes

Update Ubuntu Linux Software Using Command Line

Let us see all commands and options in details.

Ubuntu Linux server – Install updates via apt-get command line (option #1)

The commands are as follows:

  1. apt-get update : First, you use the update option to resynchronize the package index files from their sources on Ubuntu Linux via the Internet.
  2. apt-get upgrade : Second, you use the upgrade option to install the newest versions of all packages currently installed on the Ubuntu system. In other words, get security updates for your machine.
  3. sudo apt-get install package-name : Install is followed by one or more packages desired for installation. If package is already installed it will try to update to latest version.

First, open the Terminal application and type following two commands (Application > Accessories > Terminal and then type the commands as the root user). However, one can quickly open the terminal app. Hence, press Ctrl+Alt+T.

Get updated software list for Ubuntu, enter:

Type the following apt-get command:
$ sudo apt-get update
$ sudo apt update
How to install Ubuntu Linux updates via apt-get command line
To see available updates, run:
$ apt list --upgradable
Here is what I saw on Ubuntu 20.04 LTS desktop:

Listing... Done
evolution-data-server-common/focal-updates,focal-updates 3.36.5-0ubuntu1 all 
[upgradable from: 3.36.4-0ubuntu1]
evolution-data-server/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 
grub-common/focal-updates 2.04-1ubuntu26.12 amd64 [upgradable from: 
grub-efi-amd64-bin/focal-updates 2.04-1ubuntu44.2 amd64 [upgradable from: 
grub-efi-amd64-signed/focal-updates 1.167.2+2.04-1ubuntu44.2 amd64 [upgradable 
from: 1.167+2.04-1ubuntu44]
grub-efi-amd64/focal-updates 2.04-1ubuntu44.2 amd64 [upgradable from: 2
grub2-common/focal-updates 2.04-1ubuntu26.12 amd64 [upgradable from: 
libcamel-1.2-62/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 
libebackend-1.2-10/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 3
libebook-1.2-20/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 3
libebook-contacts-1.2-3/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable 
from: 3.36.4-0ubuntu1]
libecal-2.0-1/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 
libedata-book-1.2-26/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 
libedata-cal-2.0-1/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 
libedataserver-1.2-24/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 
libedataserverui-1.2-2/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 
libyelp0/focal-updates 3.36.2-0ubuntu1 amd64 [upgradable from: 3.36.0-1]
python-apt-common/focal-updates,focal-updates 2.0.0ubuntu0.20.04.5 all [
upgradable from: 2.0.0ubuntu0.20.04.4]
python3-apt/focal-updates 2.0.0ubuntu0.20.04.5 amd64 [upgradable from: 
yelp/focal-updates 3.36.2-0ubuntu1 amd64 [upgradable from: 3.36.0-1]

Update software(s) i.e. apply updates and patches on Ubuntu Linux

Type the following apt-get command:
$ sudo apt-get upgrade
$ sudo apt upgrade

Ubuntu software update command line terminal option

Installing updates on Ubuntu Linux system

Please note that above two commands will fetch files from the Internets or local mirrors. The location of update pages is specified in /etc/apt/sources.list (repositories). You need NOT to make any changes to this file until and unless you need extra repositories for your setup.

Install kernel updates on a Ubuntu LTS server

Type the following apt-get command:
$ sudo apt-get dist-upgrade
If a new kernel installed, reboot the Linux server:
$ sudo reboot

To upgrade individual software called foo type command:

$ sudo apt-get install foo
$ sudo apt-get install apache php5 mysql-server

Ubuntu Linux server – Install updates via aptitude command line (option #2)

The syntax is as follows to Update the packages list:
$ sudo aptitude update
To actually upgrade the packages, type:
$ sudo aptitude safe-upgrade

Apply Ubuntu server updates over ssh based command line session

Firstly, login to the remote Ubuntu server using ssh client:
$ ssh user@server-name-here
$ ssh

Once your logged into your server, run the following two commands:
$ sudo apt-get update
$ sudo apt-get upgrade

$ sudo aptitude update
$ sudo aptitude safe-upgrade

$ sudo apt-get update
$ sudo apt-get dist-upgrade

From the apt-get(8) page:

The 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. So, dist-upgrade command may remove some packages. The /etc/apt/sources.list file contains a list of locations from which to retrieve desired package files.

Using Ubuntu Update Manager GUI tool

Ubuntu Update Manage the GUI tool. It works like Microsoft or Red Hat update manager i.e. you will see a little icon in the kicker bar/taskbar when there are updates. It will only appear when new upgrades are available. All you have to do is click on it and follow the online instructions. You can also start the GUI tool by Clicking System > Administration > Update Manager

A note about the latest version of Ubuntu Linux

Press the Superkey (Windows key) > Type updater:

Fig.01: Ubuntu Launch the Software Updater

Fig.01: Ubuntu Launch the Software Updater

You will see the box as follows. Click on the Install now button

Fig.02: Installing updates on a Ubuntu Linux

Fig.02: Installing updates on a Ubuntu Linux

Summing up

In conclusion, keeping your system kernel and apps is an essential task for all developers and sysadmin. A patched system prevents security issues and increases system stability. Similarly, it is also possible to automatically download and apply all critical security updates on your system. Hence, please see the following tutorials:

Both apt and apt-get commands have many options. Hence, read the man page using the man command or help command:
man apt
man apt-get
apt --help


You learned how to update or upgrade Ubuntu Linux using terminal based session. The apt command or apt-get command have many more options. Therefore, I suggest that you consult the following manul pages using the help command or man command:

Next Post Previous Post
No Comment
Add Comment
comment url