-
Ghislain Durif authoredGhislain Durif authored
title: Install system programs
author: "Laurent Modolo"
if (!require("fontawesome")) {
install.packages("fontawesome")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)

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).
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
- Debian / Ubuntu: apt
- CentOS / RedHat: yum
- ArchLinux: pacman
- SUSE / OpenSUSE: zypper
- Gentoo: portage
- Alpine: apk
Packages manager install the packages in root owned folders, you need root access to be able to use them.
Solution
```sh docker run -it --volume /:/root/chroot alpine sh -c "chroot /root/chroot /bin/bash -c 'usermod -a -G sudo etudiant'" && su etudiant ```
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.
Solution
```sh sudo apt install r-base-core ```
What is the R version that you installed ? Is there a newer version of R ?
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
Updating the repository list
You can now use apt
to update your repository list dans try to reinstall r-base-core
Solution
```sh 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.
Solution
```sh 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
.
Solution
```sh sudo apt search linux-image ```
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.
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.
Solution
```sh 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.