How Do I Update Ubuntu Linux Software Using Command Line?

I 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:

    [donotprint][/donotprint]

  1. apt-get or apt commandapt-get command or apt command is the command-line tool for handling packages.
  2. aptitude command – aptitude is a text-based interface to the Debian GNU/Linux package system including Ubuntu Linux.

Update Ubuntu Linux Software Using Command Line

Let us see all commands and options.

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

The commands are as follows:

  1. apt-get update : Update is used to resynchronize the package index files from their sources on Ubuntu Linux via the Internet.
  2. apt-get upgrade : Upgrade is used to install the newest versions of all packages currently installed on the Ubuntu system.
  3. 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).

Get updated software list for Ubuntu, enter:

Type the following apt-get command:
$ sudo apt-get update
OR
$ sudo apt update

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

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

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 server:
$ sudo reboot

To upgrade individual software called foo type command:

$ sudo apt-get install foo
OR
$ 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

First, login to the remote Ubuntu server using ssh client:
$ ssh [email protected]
$ ssh [email protected]

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

OR
$ sudo aptitude update
$ sudo aptitude safe-upgrade

OR
$ 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

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

Fig.02: Installing updates on a Ubuntu Linux

This entry is 3 of 4 in the Upgrade On a Ubuntu Server Tutorial series. Keep reading the rest of the series:

  1. How to upgrade Ubuntu 16.04 to 18.04 LTS using terminal
  2. AWS Lightsail upgrade Ubuntu 16.04 LTS to 18.04 LTS
  3. How Do I Update Ubuntu Linux Softwares Using Command Line?
  4. HowTo: Upgrade To a Newer Version of Ubuntu 14.04 LTS

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.