How do I update Ubuntu using terminal command line

I am a new Ubuntu Linux user. I need to update Ubuntu Linux, but do not have GUI installed on my AWS/Google cloud server. How do I update Ubuntu using terminal? How can I upgrade Ubuntu using terminal command line?

Introduction: Ubuntu Linux is a free and open source operating system based on GNU userland and Linux kernel. Ubuntu is well known for ease of use. It is popular on both desktop and servers. One can update Ubuntu Linux using terminal bash shell. This page shows how to upgrade Ubuntu using terminal session.

How do I update Ubuntu using terminal?

  1. Open the terminal application
  2. For remote server use the ssh command to login (e.g. ssh user@server-name)
  3. Fetch update software list by running sudo apt-get update command
  4. Update Ubuntu software by running sudo apt-get upgrade command
  5. Reboot the Ubuntu box if required by running sudo reboot

Let us see all commands in details.

How do I upgrade Ubuntu using terminal?

You need to use either apt command or apt-get command. The apt command provides a high-level command line interface for the package management system. One can install new packages, update packages, remove/delete packages and performer other sysadmin duties for package management using apt.

How to sync the package index files from their sources via Internet

Run the command:
$ sudo apt-get update
$ sudo apt update

How to install the newest versions of all installed packages on Ubuntu

Execute the command:
$ sudo apt-get upgrade
$ sudo apt upgrade

You may need to reboot the Linux server if kernel was updated:
$ sudo reboot

How to update already installed package named nginx

The syntax is:
$ sudo apt install PackageNameHere
Alternatively, you can use the following syntax too:
$ sudo apt-get install PackageNameHere
Let us upgrade nginx package:
$ sudo apt install nginx
If nginx package is already installed it will try to update to latest version:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
nginx is already the newest version (1.10.3-0ubuntu0.16.04.2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


You learned how to update or upgrade Ubuntu Linux using terminal based session.

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.