Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Monday, July 30, 2018 at 22:49

Software installation, or commonly called package management is a fundamental skill to learn in using Ubuntu GNU/Linux. Without it, a user cannot add new software to their system nor troubleshoot any problem. This part is a continuation of the Part 5: Manuals before, to enable you in installing, removing, updating apps in Ubuntu with a knowledge to change repository mirror. in Ubuntu, we handle these all with APT (Advanced Packaging Tool) command lines. These all are the most basic in Ubuntu package management system. Happy learning!

Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.

Part 1 | Part 2 | Part 3 | Part 4 | Part 5

Command Lines Used

  • apt-get install
  • apt-get update
  • apt-get upgrade
  • apt-get dist-upgrade
  • apt-get remove
  • nano /etc/apt/sources.list


You will learn some new concepts:
  1. package: each software is distributed to the user as "package" file in .deb format
  2. dependency: a package depends to another packages, intended package cannot be installed unless you already have those another packages installed
  3. repository: packages and their dependencies stored in a central server called "repository"; Ubuntu user downloads all their software from this central server
  4. mirror: a repository copy; usually available in the user local city or nearby in their country
  5. package manager: a program to manage those above for you in your Ubuntu system; it is APT-GET in this tutorial

Command 1

Identify your system first. It's important.
$ lsb_release -a

Example output:
master@master:~$ lsb_release -a
No LSB modules are available.
Distributor ID: neon
Description:    KDE neon User Edition 5.11
Release:        16.04
Codename:       xenial

To make sure once again:
$ cat /etc/apt/sources.list

Example output:
master@master:~$ cat /etc/apt/sources.list
deb xenial main restricted multiverse universe

  • Those example outputs say that the Ubuntu version is xenial.
  • trusty is 14.04. xenial is 16.04. bionic is 18.04. See code name list here.
  • These means xenial user must only use xenial repository, respectively.
  • Do not mix different repositories in one system, like xenial with bionic, as it may break your system.

Command 2

$ sudo apt-get update

Example output:
master@master:~$ sudo apt-get update
[sudo] password for master:
Get:1 xenial-security InRelease [107 kB]                    
Get:2 xenial-updates InRelease [109 kB]           

Get:40 xenial InRelease [2316 B]

This ensures your system can download packages from the repository.

Command 3

Searching for packages. For example, you want to find out decent image editor and web browser.

Searching for image editor:
$ apt-cache search image program

Searching for web browser:
$ apt-cache search web browser

Example results:
master@master:~$ apt-cache search web browser
firefox - Safe and easy web browser from Mozilla

falkon - lightweight web browser based on Qt WebEngine
midori - fast, lightweight graphical web browser

master@master:~$ apt-cache search image program
gimp - The GNU Image Manipulation Program
krita - pixel-based image manipulation program
digikam - digital photo management application for KDE

Command 4

Installing. This needs internet access.
$ sudo apt-get install falkon
$ sudo apt-get install gimp

The name after 'install' is the package name you find from the search above.

Command 5

Seeing if newer version of a program is available.
$ apt-cache policy firefox
$ apt-cache policy nautilus
$ apt-cache policy libreoffice-writer
$ apt-cache policy rhythmbox

Example output:
master@master:~$ apt-cache policy firefox
  Installed: 59.0.2+build1-0ubuntu0.16.04.3
  Candidate: 61.0.1+build1-0ubuntu0.16.04.1
  Version table:
     61.0.1+build1-0ubuntu0.16.04.1 500
 *** 59.0.2+build1-0ubuntu0.16.04.3 100
     45.0.2+build1-0ubuntu1 500

  • Green line means the newest version available.
  • Yellow line, the ' *** ' one, means the installed version.
  • You can upgrade from 59 to 61.

Command 6

Upgrade individual program.

First, see if newer version available with Command 5 before:
$ apt-cache policy firefox
$ apt-cache policy nautilus

Then if available, upgrade individual package:
$ sudo apt-get install firefox
$ sudo apt-get install nautilus

Note: yes, the command here is indeed 'install' and not 'update' nor 'upgrade'.

Command 7

Uninstall individual program. This also called "remove".

First, you should know the package name. Suppose you want to remove Firefox Browser and LibreOffice Impress:
$ dpkg -l | grep firefox
$ dpkg -l | grep libreoffice | grep impress

So you would see the package names, respectively:
firefox  59.0.2+build1-0ubuntu0.16.04.3
libreoffice-impress  1:5.1.6~rc2-0ubuntu1~xenial2

Finally, remove the package name:
$ sudo apt-get remove firefox
$ sudo apt-get remove libreoffice-impress

Or join the commands into one:
$ sudo apt-get remove firefox  libreoffice-impress

Command 8

Upgrade the whole system. This often needs a lot of internet bandwidth and long time.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade

Note: you should stays in front of your monitor as it may asks your permission to config/delete something during upgrading.

Command 8

Offline installing is admittedly not easy but it's possible. You can, with this trick, install packages in an offline computer. For example, install Firefox and Rhythmbox. The easiest way is as following:

First, get[1] the package file in other computer. The file name should looks like these:

Second, copy the file into your offline computer. Better put it in your $HOME directory. Refer to Tutorial Part 1 if you forget how.

Finally[2], install individual package in that directory:
$ sudo dpkg -i firefox*.deb
$ sudo dpkg -i rhythmbox*.deb

[1] Download packages manually in the website.
[2] However, this trick is not always working. This may introduces you many unresolved dependencies.

Command 9

Resolving dependency conflicts. Sometimes, either it's because Command 8 above or unknown factor from the repository, you meet unresolved dependencies.

First aid to do is:
$ sudo apt-get -f install

This will force APT to download all dependencies needed and resolve conflicts automatically. Of course, this needs internet access as well.

Command 10

Changing repository mirror. You can change the default mirror to local mirror available in your home country as it's often faster for you. For example, changing default mirror to a Japan mirror from University of Tsukuba:

First, edit the file using nano:
$ sudo nano /etc/apt/sources.list

Second, change each URL from into and save.

Finally, reload once again:
$ sudo apt-get update

All done. Now you can install or upgrade from your local mirror.

  • See worldwide mirror list in Launchpad.
  • Some local mirrors may not have certain versions of Ubuntu repository.

to be continued...

This article is licensed under CC BY-SA 3.0.