When you are on Windows and want to download a new program, what do you do?
Usually a little research on a search engine, a look at the download sites like telecharger.com, clubic.com… and you find what you are looking for. You get an installer, you do “Next”, “Next”, “Next”, “Finish” and it’s installed. Sometimes you have to answer a little technical questions like “In which directory do you want to install this program?” .

Under Linux (and in particular under Ubuntu), it does not work at all like that: it is even simpler. Better: you will quickly realize that it is a real pleasure to install new programs and that it is even one of the strengths of a system like Ubuntu compared to Windows.

Packages and their dependencies

First of all, remember what we are going to do here only concerns Linux distributions based on Debian (Ubuntu is one of them).
Indeed, the installation of programs works differently from one distribution to another. This is precisely one of the major differences between distributions.

In Windows, you know what are called “Installers”. Typically, these are launchable.exe files that run and extract the program files to a Program Files folder.
Example: The installation program for the Trackmania Nations game on Windows is shown in the following figure.

Installation de programme sous Windows

Under Ubuntu, we don’t have installation programs; we have what we call packages.
A package is a kind of zipped folder that contains all of the program files. It comes in the form of a.deb file, in reference to DEBian. It contains all the instructions needed to install the program.

A deb package is kind of like an installer.exe in Windows with some fews differences.

  • there is a dependency management of the program;
  • you don’t need to do a search engine to find un.deb. All of the files are gathered in the same place on a single server called a repository.
Dependencies

It is very rare that a program can run on its own under Linux. Quite often it uses other programs or other “pieces of programs” called libraries. We say that programs depend on other programs to function: they have dependencies.


You have certainly encountered this problem a bit in Windows before. For example, when you install a game, you are told “You must install Direct X before you can play this game”.

Fortunately, the Debian package system is smart. Each package indicates which other packages it depends on. This allows the system to go and recover missing dependencies automatically if needed.
So you just have to say “I want to install Nano” and the system will look for all the missing dependencies on its own!

Installing package

We generally have to follow three steps to download a package:

  • sudo apt update (optional): to update our cache if it is not already done;
  • sudo apt search mypackage (optional): to search for the package we want to download if we don’t know its exact name;
  • sudo apt install mypackage: to download and install our package.
If you want a fuller description of a package, 
use sudo apt show packagename. Example:
apt-cache show lbreakout2.

remove a package


If you want to uninstall a package, you can use the command sudo apt remove packagename

sudo apt remove lbreakout2

The package will then be uninstalled from your computer.
However, this does not remove package dependencies that are no longer needed. To ask apt to also remove unnecessary dependencies, we use autoremove:

sudo apt autoremove lbreakout2

update all packages

Another particularly great feature of apt is its ability to update all the packages installed on your system at once. The program will look for new versions of all your programs and update them if a new version is available:

sudo apt upgrade
or 
sudo apt list --upgradable
Remember to make first "sudo apt update" to update the package
 cache on your machine before running an upgrade.
Indeed, apt compares the version of your installed packages with
 those present in the cache. If your cache is "old" apt will say 
"Oh bah, there is nothing new, no need for an update". So be sure 
to  make "sudo apt update" regularly to be 100% sure your cache 
is up to date.

By Shabazz

Software Engineer, MCSD, Web developer & Angular specialist

Leave a Reply

Your email address will not be published. Required fields are marked *