11  Install system programs


Laurent Modolo

Creative Commons License

Objective: Learn how to install programs in GNU/Linux

As we have seen in the 4 Unix file system session, programs are files that contain instruction for the computer to do things. Those files can be in binary or text format (with a shebang). Any of those files, present in a folder of the PATH variable are executable anywhere by the user. For system wide installation, the program files are copied within shared folder path containained in the PATH variable.

Developers don’t want to reinvent the wheel each time they want to write complex instruction in their programs, this is why they use shared library of pre-written complex instruction. This allows for quicker development, fewer bugs (we only have to debug the library once and use it many times), and also better memory management (we only load the library once and it can be used by different programs).

11.1 Package Manager

However, interdependencies between programs and libraries can be a nightmare to handle manually this is why most of the time when you install a program you will use a package manager. Package managers are system tools that will handle automatically all the dependencies of a program. They rely on repositories of programs and library which contains all the information about the trees of dependence and the corresponding files (packages).

Systemwide installation steps:

  • The user asks the package manager to install a program
  • The package manager queries its repository lists to search for the most recent package version of the program (or a specific version)
  • The package manager construct the dependency tree of the program
  • The package manager check that the new dependency tree is compatible with every other installed program
  • The package manager install the program package and all its dependencies packages in their correct version

The main difference between GNU/Linux distribution is the package manager they use

Packages manager install the packages in root owned folders, you need root access to be able to use them.


docker run -it --volume /:/root/chroot alpine sh -c "chroot /root/chroot /bin/bash -c 'usermod -a -G sudo etudiant'" && su etudiant

11.1.1 Installing R

R is a complex program that relies on loots of dependencies. Your current VM run on Ubuntu, so we are going to use the apt tool (apt-get is the older version of the apt command, synaptic is a graphical interface for apt-get).

You can check the r-base package dependencies on the website packages.ubuntu.com. Not too much dependency ? Check the sub-package r-base-core.

You can check the manual of the apt command to install r-base-core.


sudo apt install r-base-core

What is the R version that you installed ? Is there a newer version of R ?

11.1.2 Adding a new repository

You can check the list of repositories that apt checks in the file /etc/apt/sources.list.

You can add the official cran repository to your repositories list:

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu <release_name>-cran40/'

You can use the command lsb_release -sc to get your release name.

Then you must add the public key of this repository:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9

11.1.3 Updating the repository list

You can now use apt to update your repository list dans try to reinstall r-base-core


sudo apt update

The command gives you a way to list all the upgradable packages, which version of R can you install now ?

You can upgrade all the upgradable packages.


sudo apt upgrade

With the combination of update and upgrade you can keep your whole system up to date the even the kernel files is just another package. You can use apt to search for the various versions of the linux-image.


sudo apt search linux-image

11.1.4 Language specific package manager

If it’s not a good idea to have different package manager on the same system (they don’t know how the dependencies are handled by the other’s manager). You will also encounter language specific package manager:

  • ppm for Perl
  • pip for Python
  • npm for JavaScript
  • cargo for Rust
  • install.packages for R

These package managers allow you to make installation local to the user, which is advisable to avoid any conflict with the packages manager of the system.

For example, you can use the following command to install glances system wide with pip

sudo pip3 install glances

You can now try to install glances with apt

What is the glances version installed with apt, what is the one installed with pip ? What is the version of the glances of your PATH ?

Next-time use pip with the --user switch.

11.2 Manual installation

Sometimes, a specific tool that you want to use will not be available through a package manager. If you are lucky, you will find a package for your distribution. For apt the package are .deb files.

For example, you can download simplenote version 2.7.0 for your architecture here.


wget https://github.com/Automattic/simplenote-electron/releases/download/v2.7.0/Simplenote-linux-2.7.0-amd64.deb

You can then use apt to install this file.

11.3 From sources

If the program is open source, you can also download the sources and build them.


wget https://github.com/Automattic/simplenote-electron/archive/v2.7.0.tar.gz

You can use the command tar -xvf to extract this archive

When you go into the simplenote-electron-2.7.0 folder, you can see a Makefile this means that you can use the make command to build Simplenote from those files. make is a tool that read recipes (Makefiles) to build programs.

You can try to install node and npx with apt. What happened ?


sudo apt install nodejs

You can use the https://packages.ubuntu.com/ to search the name of the package containing the libnss3.so file.


sudo apt install libnss3                                                                                                                            

What now ? Installing dependencies manually is an iterative process…


sudo apt install libnss3 libatk1.0-dev libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm1                                                                                                                                

Yay we should have every lib !

What now ? A nodejs dependency is missing… After, some query on the internet we can find the solution…


sudo apt install libnss3 libatk1.0-dev libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm1
npm install --save-dev electron-window-state                                                                                                                                

And now you understand why program packaging takes time in a project, and why it’s important !

You can finalize the installation with the command make install. Usually the command to build a tool is available in the README.md file of the project.

Read the README file of the fastp program to see which methods of installation are available.

We have used the following commands:

  • apt to install packages on Ubuntu
  • pip3 to install Python packages
  • npm to install Nodejs packages
  • make to build programs from sources

Installing programs and maintain different versions of a program on the same system is a difficult task. In the next session, we will learn how to use virtualization to facilitate our job.

License: Creative Commons CC-BY-SA-4.0.
Made with Quarto.