Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • LBMC/hub/formations/unix
1 result
Show changes
Commits on Source (15)
Showing with 557 additions and 638 deletions
*.html
.DS_Store
.Rproj.user
......@@ -3,11 +3,11 @@
pages:
stage: deploy
image: lbmc/pandoc:2.11
image: carinerey/r_for_beginners
script:
- mkdir -p public/img
- mkdir -p public/
- cp -R img public/
- make
- cp img/* public/img/
artifacts:
paths:
- public
......
# Ssh
---
title: SSH
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -8,11 +38,11 @@ In the previous section, we have seen how to run scripts and complex commands on
Most of the content from this session are from [wikipedia.org](https://wikipedia.org)
## Network
# Network
First before talking about how to communicate over a network, we need to define what is a network in computational science. We can distinguish between two types of network, **circuit switching** networks and **packet switching** networks.
### circuit switching
## circuit switching
Circuit switching is the historical telephonic network architecture. When device A wants to communicate with device B, it has to establish a connection over the network. In a circuit switching network, the connections between a chain of nodes (hopefully the shortest chain) are established and fixed. Device A connects to the closest node and ask connection to Device B, this node will do the same thing to the closest node to Device B, so on and so forth until the connection reach Device B.
......@@ -20,7 +50,7 @@ If you try to call someone, who is already in a phone conversation, the line wil
![http://www.tcpipguide.com/free/diagrams/funcircuitswitching.png](./img/funcircuitswitching.png)
### packet switching
## packet switching
Packet switching is a method of grouping data over the network into packets. Each packet has a header and a payload. The header data can be read by each node to direct the packet to its destination. The header data also inform the Host 2 of the packets order. The payload contains the data that we want to transmit over the network. In packet switching, the network bandwidth is not pre-allocated like in circuit switching. Each packet is called a datagram.
......@@ -30,7 +60,7 @@ Packet switching is a method of grouping data over the network into packets. Eac
In a packet switching network when you send a flux of data (video, sound, etc.), you have the illusion of continuity like for process switching handled by the scheduler.
## **Internet Protocol** (IP)
# **Internet Protocol** (IP)
> The **Internet Protocol** (**IP**) is the principal [communications protocol](https://en.wikipedia.org/wiki/Communications_protocol) in the [Internet protocol suite](https://en.wikipedia.org/wiki/Internet_protocol_suite) for relaying [datagrams](https://en.wikipedia.org/wiki/Datagram) across network boundaries. Its [routing](https://en.wikipedia.org/wiki/Routing) function enables [internetworking](https://en.wikipedia.org/wiki/Internetworking), and essentially establishes the [Internet](https://en.wikipedia.org/wiki/Internet).
......@@ -38,7 +68,7 @@ IP has the task of delivering [packets](https://en.wikipedia.org/wiki/Packet_(in
The first major version of IP, [Internet Protocol Version 4](https://en.wikipedia.org/wiki/IPv4) (IPv4), is the dominant protocol of the Internet. Its successor is [Internet Protocol Version 6](https://en.wikipedia.org/wiki/IPv6) (IPv6), which has been in increasing [deployment](https://en.wikipedia.org/wiki/IPv6_deployment) on the public Internet since c. 2006.
### IPv4
## IPv4
An **IPv4** is composed of 4 digits ranging from 0 to 255 separated by `.` , which gives an address space of 4294967296 (2^32) addresses. Some combinations of **IPv4** are restricted:
......@@ -61,7 +91,7 @@ An **IPv4** is composed of 4 digits ranging from 0 to 255 separated by `.` , whi
| 240.0.0.0/4 | 240.0.0.0–255.255.255.254 | 268435455 | Internet | Reserved for future use.[[15\]](https://en.wikipedia.org/wiki/IPv4#cite_note-rfc3232-15) (Former Class E network). |
| 255.255.255.255/32 | 255.255.255.255 | 1 | Subnet | Reserved for the "limited [broadcast](https://en.wikipedia.org/wiki/Broadcast_address)" destination address.[[6\]](https://en.wikipedia.org/wiki/IPv4#cite_note-rfc6890-6)[[16\]](https://en.wikipedia.org/wiki/IPv4#cite_note-rfc919-16) |
### IPv6
## IPv6
An **IPv6** is composed of 8 groups of 4 digits long number separated by `:`. The numbers are in hexadecimal format (number of base 16, randing from 0 to 9 and A to F). Compared to **IPv4**, **IPv6** allows for 2^128 = 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses (approximately 3.4×10^38). For example, an IP address is: *2001:0db8:0000:0000:0000:ff00:0042:8329*
......@@ -69,13 +99,13 @@ To display your VM IP addresses you can use the following command: `ip address s
Local **IPv6** addresses start with **fe80::**
### **Domain Name System** (**DNS**)
## **Domain Name System** (**DNS**)
Instead of using IP addresses in your everyday life, you often use the domain name. The DNS is composed of many DNS servers that are hierarchically organized and decentralized. By querying the DNS with a particular domain name, the correct name server will return the corresponding IP address. For most network tools, you can use domain names (URL) or IP addresses.
![dns resolver](./img/dns_resolver.svg)
### Transmission Control Protocol (**TCP**)
## Transmission Control Protocol (**TCP**)
The **Transmission Control Protocol** (**TCP**) is one of the main [protocols](https://en.wikipedia.org/wiki/Communications_protocol) of the [Internet protocol suite](https://en.wikipedia.org/wiki/Internet_protocol_suite). TCP provide, reliable, ordered, and error-checked delivery of a stream of data between applications running on hosts communincating over an IP network.
......@@ -86,7 +116,7 @@ The **Transmission Control Protocol** (**TCP**) is one of the main [protocols](h
- includes traffic congestion control
- Heavtweight (no ordering of messages, no tracking connections, etc. It is a very simple transport layer designed on top of IP)
### **User Datagram Protocol** (**UDP**)
## **User Datagram Protocol** (**UDP**)
UDP uses a simple [connectionless communication](https://en.wikipedia.org/wiki/Connectionless_communication) model with a minimum of protocol mechanisms.
......@@ -96,7 +126,7 @@ UDP uses a simple [connectionless communication](https://en.wikipedia.org/wiki/C
- Multicast (a single datagram packet can be automatically routed without duplication to a group of subscribers)
- Lightweight (no ordering of messages, no tracking connections, etc. It is a very simple transport layer designed on top of IP)
### Port
## Port
Higher, communication protocols like TCP and UDP, also define **port**. A **port** is a communication endpoint. When software wants to communicate overt TCP or UDP it will do so using a specific **port**. Each system has **port** numbers ranging from 0 to 65535. **Port** numbered from 0 through 1023 are system **ports** used by well-known processes (you need specific rights to use them).
......@@ -122,7 +152,7 @@ Here are a list of notable port numbers:
Nowadays, **ports** provide multiplexing, which means that multiple service or communication session can use the same **port** number.
## SSH
# SSH
There are numerous other protocols ([RTP](https://en.wikipedia.org/wiki/Real-time_Transport_Protocol) for example). But most of them run over the TCP and UDP protocols. **SSH** or **Secure Shell** is one of them. SSH is a [cryptographic](https://en.wikipedia.org/wiki/Cryptography) [network protocol](https://en.wikipedia.org/wiki/Network_protocol) for operating network services securely over an unsecured network.
......@@ -140,25 +170,25 @@ ps -el | grep "ssh"
SSH uses [Public-key cryptography (or asymmetric cryptography](https://en.wikipedia.org/wiki/Public-key_cryptography)), to secure it’s communications.
### Public-key cryptography
## Public-key cryptography
[Public-key cryptography (or asymmetric cryptography](https://en.wikipedia.org/wiki/Public-key_cryptography)), is a cryptographic system which uses pairs of [keys](https://en.wikipedia.org/wiki/Cryptographic_key): *public keys* (which may be known to others), and *private keys* (which may never be known by any except the owner).
A cryptographic algorithm is used to generate a pair of *public* and *private* keys from a large random number. Then, the 3 following scheme can be used to secure communication:
### Communicate with the server
## Communicate with the server
The server sent a public key to the client on the first connection.
![public_key_encryption](./img/public_key_encryption.png)
### Share a secret
## Share a secret
Can be used to share public keys (see [Diffie-Hellman)](https://fr.wikipedia.org/wiki/%C3%89change_de_cl%C3%A9s_Diffie-Hellman).
![public_key_shared_secret](./img/public_key_shared_secret.png)
### Authentification
## Authentification
- The server sends a random string of characters to the client
- The client crypt the random string and send it back to the server
......@@ -166,7 +196,7 @@ Can be used to share public keys (see [Diffie-Hellman)](https://fr.wikipedia.org
![private_key_signing](./img/private_key_signing.png)
## SSH Server
# SSH Server
By default, on the IFB, password authentication is disabled to enforce the use of public key based authentication. To learn `ssh` command we are going to enable this option on your VMs. Find the`sshd` configuration file and open it with the editor of your choice.
......@@ -223,7 +253,7 @@ sudo passwd student
Give the password and your IP on the chat.
## SSH client
# SSH client
To connect of an SSH server you can use the following command:
......@@ -241,7 +271,7 @@ Check the content of the `~/.ssh/` folder, where is saved the server public key
Congratualtion you are connected on a VM through another VM !
### Key authentication
## Key authentication
Every time, that you want to connect to the ssh server, you have to type your account password, this password is encrypted and send over the network. Instead you can use a pair of private and public key to authenticate yourself.
......@@ -279,11 +309,11 @@ ssh login@IP_adress -i ~/.ssh/id_ed25519_otherVM
Congratulations, you authenticated yourself on a remote server without sending your password over the network !
## SSH based tools
# SSH based tools
Sometime, you want to do other things than executing commands on a remove computer. For example, you may want to transfer files over the network.
### scp
## scp
The `scp` command comes with the `ssh` client installation you can use it to transfer file from your computer to the ssh sever:
......@@ -301,7 +331,7 @@ scp login@IP_adress:remote/path local/path
To transfer directory you can use the `-r` witch
### rsync
## rsync
`scp` Is a basic command for file transfer. If you want advanced process bar and file integrity checking, you can use the `rsync` command instead.
......@@ -313,13 +343,13 @@ rsync -auv local/path login@IP_adress:remote/path
Will only transfer files from `local/path` not already present in `remote/path`. The `-c` switch will compute a checksum of the file locally and remotely to be certain that they are identical.
### sshfs
## sshfs
You can use the `sshfs` command to mount a remote folder over ssh on your computer.
## SSH tips
# SSH tips
### IFB authentication
## IFB authentication
The default authentication method for the IFB uses keys generated with the `rsa` algorithm
......@@ -333,7 +363,7 @@ Instead of using the `ssh-copy-id` command, you are going to copy paste your pub
You can now use the [RainBio catalogue](https://biosphere.france-bioinformatique.fr/catalogue/) to launch any available VMs and connect to is with SSH from your current VM.
### SSH configuration
## SSH configuration
Long ssh command can be tedious to use. This is why we are now going to explore the last file in the `.ssh` folder: `.ssh/config`.
......@@ -388,7 +418,6 @@ Host work-ens
With the command `ssh work-ens`, the `ssh` client is going to first connect to `ens` and then from `ens` to the `ip.ip.ip.ip` server.
In the next session, we are going to learn how to [install system-wide programs](./11_install_system_programs.html) like the one managed by `systemd`
> We have used the following commands:
>
......@@ -397,3 +426,4 @@ In the next session, we are going to learn how to [install system-wide programs]
> - scp to copy files
> - rsync to copy files
In the next session, we are going to learn how to [install system-wide programs](./11_install_system_programs.html) like the one managed by `systemd`
# Install system programs
---
title: Install system programs
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -8,7 +38,7 @@ As we have seen in the [4 unix file system](http://perso.ens-lyon.fr/laurent.mod
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](http://perso.ens-lyon.fr/laurent.modolo/unix/6_unix_processes.html#processes-tree) (we only load the library once and it can be used by different programs).
## Package Manager
# 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](https://en.wikipedia.org/wiki/Package_manager). [Package manager](https://en.wikipedia.org/wiki/Package_manager) 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**).
......@@ -39,7 +69,7 @@ docker run -it --volume /:/root/chroot alpine sh -c "chroot /root/chroot /bin/ba
</p>
</details>
### Installing R
## 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`)
......@@ -57,7 +87,7 @@ 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
## Adding a new repository
You can check the list of repositories that `apt` checks in the file `/etc/apt/sources.list`.
......@@ -75,7 +105,7 @@ 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
## Updating the repository list
You can now use `apt` to update your repository list dans try to reinstall **r-base-core**
......@@ -111,7 +141,7 @@ sudo apt search linux-image
### Language specific package manager
## 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:
......@@ -138,7 +168,7 @@ Next-time use `pip` with the `--user` switch.
## Manual installation
# 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.
......@@ -154,7 +184,7 @@ wget https://github.com/Automattic/simplenote-electron/releases/download/v2.7.0/
You can then use `apt` to install this file.
## From sources
# From sources
If the program is open source, you can also [download the sources](https://github.com/Automattic/simplenote-electron/archive/v2.7.0.tar.gz) and build them.
......@@ -219,7 +249,6 @@ You can finalize the installation with the command `make install`. Usually the c
Read the `README` file of the [fastp](https://github.com/OpenGene/fastp) program to see which methods of installation are available.
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](./12_virtualization.html) to facilitate our job.
> We have used the following commands:
>
......@@ -229,4 +258,5 @@ Installing programs and maintain different versions of a program on the same sys
> - 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](./12_virtualization.html) to facilitate our job.
# Install system programs
---
title: Virtualization
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -16,21 +46,21 @@ To avoid the overhead of simulating every component of the **guest** system, whi
There are different levels of virtualisation which correspond to different levels of isolation between the virtual machine (**guest**) and the real computer (**host**).
## Full virtualization
# Full virtualization
A key challenge for full virtualization is the interception and simulation of privileged operations, such as I/O instructions. The effects of every operation performed within a given virtual machine must be kept within that virtual machine – virtual operation cannot be allowed to alter the state of any other virtual machine, the control program, or the hardware. Some machine instructions can be executed directly by the hardware, since their effects are entirely contained within the elements managed by the control program, such as memory locations and arithmetic registers. But other instructions that would "pierce the virtual machine" cannot be allowed to execute directly; they must instead be trapped and simulated. Such instructions either access or affect state information that is outside the virtual machine.
## Paravirtualization
# Paravirtualization
In paravitualization, the virtual hardware of the **guest** system is similar to the hardware of the **host**. The goal is to reduce the portion of the **guest** execution time spent to simulate hardware which is the same as the **host** hardware. The paravirtualization provides specially defined **hooks** to allow the **guest** and **host** to request and acknowledge these tasks, which would otherwise be executed in the virtual domain (where execution performance is worse).
A hypervisor provides the virtualization of the underlying computer system. In [full virtualization](https://en.wikipedia.org/wiki/Full_virtualization), a guest operating system runs unmodified on a hypervisor. However, improved performance and efficiency is achieved by having the guest operating system communicate with the hypervisor. By allowing the guest operating system to indicate its intent to the hypervisor, each can cooperate to obtain better performance when running in a virtual machine. This type of communication is referred to as paravirtualization.
## OS-level virtualization
# OS-level virtualization
**OS-level virtualization** is an [operating system](https://en.wikipedia.org/wiki/Operating_system) paradigm in which the [kernel](https://en.wikipedia.org/wiki/Kernel_(computer_science)) allows the existence of multiple isolated [user space](https://en.wikipedia.org/wiki/User_space) instances. Such instances, called **containers** may look like real computers from the point of view of programs running in them. Programs running inside a container can only see the container's contents and devices assigned to the container.
## VirtualBox
# VirtualBox
VirtualBox is own by oracle, you can add the following repository to get the last version:
......@@ -100,7 +130,7 @@ VBoxManage startvm Ubuntu20.04
Why did this last command fail ? Which kind of virtualisation VirtualBox is using ?
## Docker
# Docker
Docker is an **OS-level virtualization** system where the virtualization is managed by the `docker` daemon.
......@@ -164,7 +194,7 @@ docker rmi rocker/rstudio:3.2.0
Try to run the `mcr.microsoft.com/windows/servercore:ltsc2019` container, what is happening ?
### Building your own container
## Building your own container
You can also create your own container by writing a container recipe. For Docker this file is named `Dockerfile`
......@@ -196,7 +226,7 @@ docker build ./ -t 'ubuntu_with_htop'
## Singularity
# Singularity
Like Docker, Singularity is an **OS-level virtualization**. This main difference with docker is that the user is the same within and outside a container. Singularity is available on the [neuro.debian.net](http://neuro.debian.net/install_pkg.html?p=singularity-container) repository, you can add this source with the following commands:
......
---
title: First step in a terminal
title: Understanding a computer
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
# Understanding a computer
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" />
</a>
Objective: understand the relations between the different components of a computer
---
# Which parts are necessary to define a computer ?
---
# Computer components
## CPU (Central Processing Unit)
![CPU](./img/amd-ryzen-7-1700-cpu-inhand1-2-1500x1000.jpg)
![CPU](./img/amd-ryzen-7-1700-cpu-inhand1-2-1500x1000.jpg){width=100%}
## Memory
### RAM (Random Access Memory)
<img src="./img/220px-Swissbit_2GB_PC2-5300U-555.jpg" alt="RAM" style="zoom:150%;" />
### HDD (Hard Disk Drive) / SSD (Solid-State Drive)
<img src="./img/220px-Laptop-hard-drive-exposed.jpg" alt="HDD" style="zoom:150%;" />
<img src="./img/220px-SSD_Samsung_960_PRO_512GB_-_front_and_back_-_2018-05-27.jpg" alt="SSD" style="zoom:150%;" />
![RAM](./img/ram.png){width=100%}
### HDD (Hard Disk Drive) / SSD (Solid-State Drive)
![HDD](./img/SSD.jpeg){width=100%}
![SSD](./img/hdd.png){width=100%}
## Motherboard
![motherboard](./img/motherboard.jpg)
![motherboard](./img/motherboard.jpg){width=100%}
## GPU (Graphical Processing Unit)
![GPU](./img/foundation-100046736-orig.jpg)
![GPU](./img/foundation-100046736-orig.jpg){width=100%}
## Alimentation
![Alim](./img/LD0003357907_2.jpg)
![Alim](./img/LD0003357907_2.jpg){width=100%}
---
# Computer model: universal Turing machine
![width:20% height:20%](./img/lego_turing_machine.jpg)
![width:20% height:20%](./img/lego_turing_machine.jpg){width=100%}
---
# As simple as a Turing machine ?
![universal_truing_machine](./img/universal_truing_machine.png)
![universal_truing_machine](./img/universal_truing_machine.png){width=100%}
- A tape divided into cells, one next to the other. Each cell contains a symbol from some finite alphabet.
- A head that can read and write symbols on the tape and move the tape left and right one (and only one) cell at a time.
......@@ -69,7 +96,7 @@ Objective: understand the relations between the different components of a comput
---
# Unified Extensible Firmware Interface (UEFI)
# Unified Extensible Firmware Interface (UEFI)
Advantages:
......@@ -94,9 +121,10 @@ Disadvantages:
- The first thing on the tape of a Turing machine
## Kernel
> The kernel provides the most basic level of control over all of the computer's hardware devices. It manages memory access for programs in the RAM, it determines which programs get access to which hardware resources, it sets up or resets the CPU's operating states for optimal operation at all times, and it organizes the data for long-term non-volatile storage with file systems on such media as disks, tapes, flash memory, etc.
![Kernel](./img/220px-Kernel_Layout.svg.png)
[Kernel](./img/220px-Kernel_Layout.svg.png){width=100%}
---
......@@ -104,9 +132,10 @@ Disadvantages:
> Unix is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix,
[![Unix history](./img/1920px-Unix_timeline.en.svg.png)](https://upload.wikimedia.org/wikipedia/commons/7/77/Unix_history-simple.svg)
[![Unix history](./img/1920px-Unix_timeline.en.svg.png){width=100%}](https://upload.wikimedia.org/wikipedia/commons/b/b5/Linux_Distribution_Timeline_21_10_2021.svg)
The ones you are likely to encounter:
- [macOS](https://en.wikipedia.org/wiki/MacOS)
- [BSD (Berkeley Software Distribution) variant](https://www.freebsd.org/)
- [GNU/Linux](https://www.kernel.org/)
......@@ -118,18 +147,20 @@ The philosophy of UNIX is to have a large number of small software which do few
Linux is the name of the kernel which software, to get a full OS, Linux is part of the [GNU Project](https://www.gnu.org/).
The GNU with Richard Stallman introduced the notion of Free Software:
1. The freedom to run the program as you wish, for any purpose.
2. The freedom to study how the program works, and change it so it does your computing as you wish. Access to the source code is a precondition for this.
3. The freedom to redistribute copies so you can help others.
4. The freedom to distribute copies of your modified versions to others. By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this.
![Richard Stallman](https://audio-video.gnu.org/video/TEDxGE2014_Stallman05_LQ.webm)
You can find a [list of software licenses](https://www.gnu.org/licenses/license-list.html)
<video width="100%" controls>
<source src="https://audio-video.gnu.org/video/TEDxGE2014_Stallman05_LQ.webm" type="video/webm">
Your browser does not support the video tag.
</video>
[Instead of installing GNU/Linux on your computer, you are going to learn to use the IFB Cloud.](./2_using_the_ifb_cloud.html)
See this [presentation](https://plmlab.math.cnrs.fr/gdurif/presentation_foss/-/blob/main/presentation/presentation_DURIF_foss.pdf) (in french) for a quick introduction about **software license** and **free/open source software**.
[Instead of installing GNU/Linux on your computer, you are going to learn to use the IFB Cloud.](./2_using_the_ifb_cloud.html)
---
title: IFB (Institu Français de bio-informatique) Cloud
title: IFB (Institut Français de bio-informatique) Cloud
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
# IFB (Institu Français de bio-informatique) Cloud
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" />
</a>
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
Objective: Start and connect to an appliance on the IFB cloud
Instead of working on your computer where you don't have an Unix-like OS or have limited right, we are going to use the [IFB (Institu Français de bio-informatique) Cloud]( https://biosphere.france-bioinformatique.fr/).
Instead of working on your computer where you don't have an Unix-like OS or have limited right, we are going to use the [IFB (Institut Français de bio-informatique) Cloud]( https://biosphere.france-bioinformatique.fr/).
## Creating an IFB account
# Creating an IFB account
1. Access the [**https://biosphere.france-bioinformatique.fr/**](https://biosphere.france-bioinformatique.fr/) website
2. On the top right (First) steps with GNU/Linux
Instead of working on your computer where you don't have an Unix-like OS or have limited right, we are going to use the [IFB (Institu Français de bio-informatique) Cloud]( https://biosphere.france-bioinformatique.fr/). For this you will need:
Instead of working on your computer where you don't have an Unix-like OS or have limited right, we are going to use the [IFB (Institut Français de bio-informatique) Cloud]( https://biosphere.france-bioinformatique.fr/). For this you will need:
1. Access the [**https://biosphere.france-bioinformatique.fr/**](https://biosphere.france-bioinformatique.fr/) website
2. On the top right of the screen click on <img src="./img/signin_ifb.png" alt="sign in" style="zoom:150%;" />
......@@ -26,17 +55,17 @@ Instead of working on your computer where you don't have an Unix-like OS or have
5. Login
6. Complete the form with your **Name**, **First Name**, **Town** and **Zip Code**. You can ignore the other field and click on **accept**.
7. Go to your **Groups** parameters on the top right ![group_selection_ifb](./img/group_selection_ifb.png)
8. Click on ![join_a_group](./img/join_a_group.png) and type **LBMC Unix 2020**
8. Click on ![join_a_group](./img/join_a_group.png) and type **LBMC Unix 2022**
9. You can click on the **+** sign to register and wait to be accepted in the group
## Starting the LBMC Unix 2020 appliance
# Starting the LBMC Unix 2022 appliance
To follow this practical you will need to start the **[LBMC Unix 2020](https://biosphere.france-bioinformatique.fr/catalogue/appliance/177/)** appliance from the [IFB Cloud](https://biosphere.france-bioinformatique.fr/) and click on the ![start](./img/start_VM.png) button after login with your account.
To follow this practical you will need to start the **[LBMC Unix 2022](https://biosphere.france-bioinformatique.fr/catalogue/appliance/177/)** appliance from the [IFB Cloud](https://biosphere.france-bioinformatique.fr/) and click on the ![start](./img/start_VM.png) button after login with your account.
In the IFB jargon, appliance means **virtual machine** (VM). Remember how a universal Turing machine can run any programs ? A virtual machine, is a simulation program, simulating a physical computer. VM's have the following advantages:
- Copies of the VM will be identical (there will be no differences between your running *LBMC Unix 2020 appliance* and mine )
- Upon starting the VM is reset to the *LBMC Unix 2020 appliance* state
- Copies of the VM will be identical (there will be no differences between your running *LBMC Unix 2022 appliance* and mine )
- Upon starting the VM is reset to the *LBMC Unix 2022 appliance* state
- You can break everything in your VM, terminate it and start a new one.
To access to your appliance you can go to the [**myVM** tab](https://biosphere.france-bioinformatique.fr/cloud/)
......@@ -53,7 +82,7 @@ You will need to start this appliance at the start of each session of this cours
The ![hourglass](./img/wait_my_appliances_ifb.png) symbol indicates that your appliance is starting.
## Accessing the LBMC Unix 2020
# Accessing the LBMC Unix 2022
You can open the **https** link next to the termination button of your appliance in a new tab. You will have the following message
......
---
title: First step in a terminal
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
# First step in a terminal
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c("top", "right"),
color = "white",
tooltip_message = "Click to copy",
tooltip_success = "Copied !"
)
```
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" />
</a>
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -18,7 +49,7 @@ What is the distribution installed on your VM ?
You can go to this distribution website and have a look at the list of firms using it.
## Shell
# Shell
A command-line interpreter (or shell), is a software designed to read lines of text entered by a user to interact with an OS.
......@@ -45,7 +76,7 @@ You can identify the following information from your prompt: **etudiant** is you
On Ubuntu 20.04, the default shell is [Bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)) while on recent version of macOS it’s [zsh](https://en.wikipedia.org/wiki/Z_shell). There are [many different shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters), for example, Ubuntu 20.04 also has [sh](https://en.wikipedia.org/wiki/Bourne_shell) installed.
## Launching Programs
# Launching Programs
You can launch every program present on your computer from the shell. The syntax will always be the following:
......@@ -95,7 +126,7 @@ cal 2 1999
What is the difference for the parameter value `2` in the first and third command ?
## Moving around
# Moving around
For the `cal` program, the position in the file system is not important (it’s not going to change the calendar). However, for most tools that are able to read or write files, it’s important to know where you are. This is the first real difficulty with command line interface: you need to remember where you are.
......@@ -127,7 +158,7 @@ What happens when you type `cd` without any argument ?
What is the location shown in your prompt ? Is it coherent with the `pwd` information ? Can you `cd` to the `pwd` path ?
When we move around a file system, we often want to see what is in a given folde. We want to **l**i**s**t the directory content. Go back to the `/home` directory and use to the `ls` command see how many have a home directory there.
When we move around a file system, we often want to see what is in a given folder. We want to **l**i**s**t the directory content. Go back to the `/home` directory and use to the `ls` command see how many people have a home directory there.
We will see various options for the `ls` command, throughout this course. Try the `-a` option.
......@@ -137,9 +168,9 @@ ls -a
What changed compared to the `ls` command without this option ?
Go to your home folder with the bare `cd` command and run the `ls -a` command again. The `-a` option makes the `ls` command list hidden files and folders. On Unix systems, hidden files and folders are all files and folders whose name starts with a "**.**".
Go to your home folder with the bare `cd` command and run the `ls -a` command again. The `-a` option makes the `ls` command list hidden files and folders. On Unix systems, hidden files and folders are all files and folders whose name starts with a `.`.
Can you `cd` to "**.**" ?
Can you `cd` to `.` ?
```sh
cd .
......@@ -147,7 +178,7 @@ cd .
What happened ?
Can you cd to "**..**" ?
Can you cd to `..` ?
```sh
cd ..
......
---
title: GNU/Linux file system
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
# GNU/Linux file system
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c("top", "right"),
color = "white",
tooltip_message = "Click to copy",
tooltip_success = "Copied !"
)
```
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" />
</a>
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -28,19 +58,19 @@ This file system is organized as a tree. As you have seen, every folder has a pa
Every file can be accessed by an **absolute path** starting at the root. Your user home folder can be accessed with the path `/home/etudiant/`. Go to your user home folder.
We can also access file with a **relative path**, using the special folder "**..**". From your home folder, go to the *ubuntu* user home folder without passing by the root (we will see use of the "**.**" folder later).
We can also access files with a **relative path**, using the special folder `..`. From your home folder, go to the *ubuntu* user home folder without passing by the root (we will see use of the `.` folder later).
## File Types
# File Types
As you may have guessed, every file type is not the same. We have already seen that common file and folder are different. Here are the list of file types:
As you may have guessed, every file type is not the same. We have already seen that common file and folder are different. Here is the list of file types:
- **-** common files
- **d** folders
- **l** links
- **b** disk
- **c** special files
- **s** socket
- **p** named pipes
- `-` common files
- `d` folders
- `l` links
- `b` disk
- `c` special files
- `s` socket
- `p` named pipes
To see the file type you can type the command
......@@ -48,61 +78,61 @@ To see the file type you can type the command
ls -la
```
The first column will tell you the type of the file (here we have only the type "**-**" and "**d**" ). We will come back on the other information later. An other less used command to get fine technical information on a file is the command `stat [file_name]`. Can you get the same information as `ls -la` with `stat` ?
The first column will tell you the type of the file (here we have only the type `-` and `d`). We will come back on the other information later. Another less used command to get fine technical information on a file is the command `stat [file_name]`. Can you get the same information as `ls -la` with `stat` ?
## Common Structure
# Common Structure
From the root of the system (**/**), most of the Unix-like distribution will share the same folder arborescence. On macOS, the names will be different because when you sell the most advanced system in the world you need to rename things, with more advanced names.
From the root of the system (`/`), most of the Unix-like distribution will share the same folder tree structure. On macOS, the names will be different because when you sell the most advanced system in the world you need to rename things, with more advanced names.
### `/home`
## `/home`
You already know this one. You will find all your file and your configuration files here. Which configuration file can you identify in your home ?
### `/boot`
## `/boot`
You can find the Linux kernel and the boot manager there. What is the name of your boot manager (process by elimination) ?
You can see a new type of file here, the type "**l**". What it the version of the **vmlinuz** kernel ?
You can see a new type of file here, the type `l`. What it the version of the **vmlinuz** kernel ?
### `/root`
## `/root`
The home directory of the super user, also called root (we will go back on him later). Can you check its configuration file ?
### `/bin`, `/sbin`, `/usr/bin` and `/opt`
## `/bin`, `/sbin`, `/usr/bin` and `/opt`
The folder containing the programs used by the system and its users. Programs are simple file readable by a computer, these files are often in **bin**ary format which means that it’s extremely difficult for a human to read them.
What is the difference between **/bin** and **/usr/bin** ?
What is the difference between `/bin` and `/usr/bin` ?
**/sbin** stand for system binary. What are the names of the programs to power off and restart your system ?
`/sbin` stand for system binary. What are the names of the programs to power off and restart your system ?
**/opt** is where you will find the installation of non-conventional programs (if you don’t follow [the guide of good practice of the LBMC](http://www.ens-lyon.fr/LBMC/intranet/services-communs/pole-bioinformatique/ressources/good_practice_LBMC), you can put your bioinformatics tools with crapy installation procedure there).
`/opt` is where you will find the installation of non-conventional programs (if you don’t follow [the guide of good practice of the LBMC](http://www.ens-lyon.fr/LBMC/intranet/services-communs/pole-bioinformatique/ressources/good_practice_LBMC), you can put your bioinformatics tools with crapy installation procedure there).
### `/lib` and `/usr/lib`
## `/lib` and `/usr/lib`
Those folder contains system libraries. Libraries are a collection of pieces of codes usable by programs.
What is the difference between **/lib** and **/usr/lib**.
What is the difference between `/lib` and `/usr/lib`.
Search information on the `/lib/gnupg` library on the net.
### `/etc`
## `/etc`
The place where system configuration file and default configuration file are. What is the name of the default configuration file for `bash` ?
### `/dev`
## `/dev`
Contains every peripheric
What is the type of the file `stdout` (you will have to follow the links)?
With the command `ls -l` can you identify files of type "**b**" ?
With the command `ls -l` can you identify files of type `b` ?
Using `less` can you visualize the content of the file `urandom` ? What about the file `random` ?
What is the content of `/dev/null`?
### `/var`
## `/var`
Storage space for variables and temporary files, like system logs, locks, or file waiting to be printed...
......@@ -116,15 +146,15 @@ You can navigate the file with the navigation arrows. Which group the user `ubun
To close the `less` you can press `Q`. Try the opposite of `less`, what are the differences ?
What is the type of the file `autofs.fifo-var-autofs-ifb` in the `run` folder ? From **fifo** in the name, can you guess the function of the "**p**" file ?
What is the type of the file `autofs.fifo-var-autofs-ifb` in the `run` folder ? From **fifo** in the name, can you guess the function of the `p` file ?
There are few examples of the last type of file in the `run` folder, in which color the command `ls -l` color them ?
### `/tmp`
## `/tmp`
Temporary space. **Erased at each shutdown of the system !**
### `/proc`
## `/proc`
Information on the system resources. This file system is virtual. What do we mean by that ?
......@@ -136,7 +166,7 @@ From the `cpuinfo` file get the brand of the cpu simulated by your VM.
From the `meminfo` file retrieve the total size of RAM
## Links
# Links
With the command `ls -l` we have seen some links, the command `stat` can give us more information on them
......@@ -146,7 +176,7 @@ stat /var/run
What is the kind of link for `/var/run` ?
Most of the time, when you are going to work with links, you will work with this kind of link. You can create a **l**i**n**k with the command `ln` and the option `-s` for **s**ymbolic.
Most of the time, when you are going to work with links, you will work with this kind of link. You can create a **l**i**n**k with the command `ln` and the option `-s` for a **s**ymbolic.
The first argument after the option of the `ln` command is the target of the link, the second argument is the link itself:
......@@ -182,13 +212,13 @@ ln .bashrc bashrc_linkb
Use `stat` to also study `bashrc_linka` and `bashrc_linkb`.
What happen when you delete `bashrc_linka` ?
What happens when you delete `bashrc_linka` ?
To understand the notion of **Inode** we need to know more about storage systems.
## Disk and partition
# Disk and partition
On a computer, the data are physically stored on a media (HDD, SSD, USB key, punch card...)
......@@ -200,11 +230,11 @@ You cannot dump data directly into the disk, you need to organize things to be a
![disk](./img/disk.png)
Each media is divided into partition:
Each media is divided into partitions:
![partitions](./img/partition.png)
The media is divided into one or many partition, each of which have a file system type. Examples of file system type are:
The media is divided into one or many partition, each of which have a file system type. Examples of file system types are
- fat32, exFAT
- ext3, ext4
......@@ -225,8 +255,8 @@ Find which disk is mounted at the root of the file tree.
> We have seen the commands:
>
> - `stat` to display information on a file
> - `less` to visualise the content of a file
> - `ln` to create link
> - `less` to visualize the content of a file
> - `ln` to create links
> - `mount` to list mount points
[That’s all for the Unix file system, we will come back to it from time to time but for now you can head to the next section.](./5_users_and_rights.html)
---
title: Users and rights
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
# Users and rights
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -23,7 +48,7 @@ There can also be other users who
- belong to groups
- the groups also have rights
## File rights
# File rights
Each file is associated with a set of rights:
......@@ -38,7 +63,7 @@ Check your set of rights on your `.bashrc` file
ls -l ~/.bashrc
```
The first column of the `ls -l` output show the status of the rights on the file
The first column of the `ls -l` output shows the status of the rights on the file
![user_rights](./img/user_right.png)
......@@ -96,7 +121,7 @@ What can you conclude on the symbols `+` , `=`, `-` and `,` with the `chmod` com
> | `-r--r--r--` | 0444 | read |
> | `-r-xr-xr-x` | 0555 | read & execute |
> | `-rw-rw-rw-` | 0666 | read & write |
> | `-rwxr-----` | 0740 | owner can read, write, & execute; group can only read; others have no permissions |
> | `-rwxr-----` | 0740 | owner can read, write, & execute; group can only read; others have no permission |
The default group of your user is the first in the list of the groups you belong to. You can use the command `groups` to display this list. What is your default group ?
......@@ -128,7 +153,7 @@ Create a symbolic link (`ln -s`) to your **.bashrc** file, what are the default
Can you remove the writing right of this link ? What happened ?
## Users and Groups
# Users and Groups
We have seen how to change the right associated with the group, but what about changing the group itself ? The command `chgrp` allows you to do just that:
......@@ -162,7 +187,7 @@ Copy the `mkdir` tool to your home directory. Can you remove execution rights fo
You cannot change the owner of a file, but you can always allow another user to copy it and change the rights on its copy.
## Getting admin access
# Getting admin access
Currently you don’t have administrative access to your VM, this means that you don’t have the password to the *root* account. Another way to get administrative access in Linux is to use the `sudo` command.
......@@ -200,7 +225,7 @@ You can try again the `chown` command with the `sudo` command.
Check the content of the file `/etc/shadow` , what is the utility of this file (you can get help from the `man` command).
## Creating Users
# Creating Users
You can add a new user to your system with the command `useradd`
......@@ -208,14 +233,14 @@ You can add a new user to your system with the command `useradd`
useradd -m -s /bin/bash -g users -G adm,docker student
```
- `-m` create a hone directory
- `-m` create a home directory
- `-s` specify the shell to use
- `-g` the default group
- `-G` the additional groups
To log into another account you can use the command `su`
What is the difference between the two following command ?
What is the difference between the two following commands ?
```sh
su student
......@@ -227,7 +252,7 @@ sudo su student
What append when you don't specify a login with the `su` command ?
## Creating groups
# Creating groups
You can add new groups to your system with the command `groupadd`
......@@ -235,7 +260,7 @@ You can add new groups to your system with the command `groupadd`
sudo groupadd dummy
```
Then you can add users to these group with the command `usermod`
Then you can add users to this group with the command `usermod`
```sh
sudo usermod -a -G dummy student
......@@ -247,7 +272,7 @@ And check the result:
groups student
```
To remove an user from a group you can rewrite it's list of group with the command `usermod`
To remove an user from a group you can rewrite its list of groups with the command `usermod`
```sh
sudo usermod -G student student
......@@ -255,11 +280,11 @@ sudo usermod -G student student
Check the results.
## Security-Enhanced Linux
# Security-Enhanced Linux
While what you have seen in this section hold true for every Unix system, additionnal rules can be applied to control the rights in Linux. This is what is called [SE Linux](https://en.wikipedia.org/wiki/Security-Enhanced_Linux) (**s**ecurity-**e**nhanced **Linux**)
While what you have seen in this section hold true for every Unix system, additional rules can be applied to control the rights in Linux. This is what is called [SE Linux](https://en.wikipedia.org/wiki/Security-Enhanced_Linux) (**s**ecurity-**e**nhanced **Linux**)
When SE Linux is enabled on a system, every **processes** can be assigned a set of right. This is how, on Android for example, some programs can access your GPS while other cannot etc. In this case it's not the user rights that prevail, but the **process** launched by the user.
When SE Linux is enabled on a system, every **process** can be assigned a set of rights. This is how, on Android for example, some programs can access your GPS while others cannot, etc. In this case it's not the user rights that prevail, but the **process** launched by the user.
> We have seen the commands:
>
......@@ -273,6 +298,6 @@ When SE Linux is enabled on a system, every **processes** can be assigned a set
> - `sudo` to borrow **root** rights
> - `groupadd` to create groups
> - `groups` to list groups
> - `usermod`to manipulate user's to groups
> - `usermod`to manipulate users' groups
[To understand more about processes you can head to the next section.](./6_unix_processes.html)
---
title: Unix Processes
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
---
```
# Unix Processes
......@@ -22,7 +48,7 @@ Your shell is a process to manipulate other processes.
Some commands in your shell don’t have an associated process, for example there is no `cd` program, it’s a functionality of your shell. The `cd` command tell your `bash` process to do something not to fork another process.
## Process attributes
# Process attributes
- PID : the **p**rocess **id**entifier is an integer, at a given time each PID is unique to a process
- PPID : the **p**arent **p**rocess **id**entifier is the PID of the process that has stared the current process
......@@ -69,7 +95,7 @@ ps -l -C systemd
Who launched the first `systemd` process ?
## Processes tree
# Processes tree
From PPID to PPID, you can guess that like the file system, processes are organized in a tree. The command `pstree` can give you a nice representation of this tree.
......@@ -116,7 +142,7 @@ Launch the `stress` for 1 cpu and 3600 second.
You don’t have a prompt, it means that the last command (`stress`) is running.
## Terminate
# Terminate
Instead of taking a nap and come back at the end of this session, we may want to interrupt this command. The first way to do that is to ask the system to terminate the `stress` process.
......@@ -160,7 +186,7 @@ A process with a PPID of 1 is called a **daemon**, daemons are processes that ru
Kill the remaining `stress `processes with the command `pkill`. You can check the **man**ual on how to do that.
## Suspend
# Suspend
Launch `htop` then press `ctrl` + `z`. What happened ?
......@@ -200,7 +226,7 @@ Bring the 2nd `htop` to the foreground. Put it back to the background with `ctrl
The command `bg` allow you to resume a job stopped in the background. You can restart your stopped `stress` process with this command. You can use the `kill %N` syntax to kill your two `stress` processes.
## Priority
# Priority
We have seen that we can launch a `stress `process to use 100% of a cpu. Launch two `stress` process like that in the background.
......
---
title: Unix Streams and pipes
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
# Steams and pipes
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -37,7 +60,7 @@ cat .bashrc
## Streams manipulation
# Streams manipulation
You can use the `>` character to redirect a flux toward a file. The following command make a copy of your `.bashrc` files.
......@@ -100,7 +123,7 @@ cal 2&>> my_redirection
## Pipes
# Pipes
The last stream manipulation that we are going to see is the pipe which transforms the **stdout** of a process into the **stding** of the next. Pipes are useful to chain multiples simple operations. The pipe operator is `| `
......
---
title: Text manipulation
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
# Text manipulation
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -14,7 +36,7 @@ Objective: Learn basics way to work with text file in Unix
One of the great thing with command line tools is that they are simple and fast. Which means that they are great for handle large files. And as bioinformaticians you have to handle large file, so you need to use command line tools for that.
## Text search
# Text search
The file [hg38.ncbiRefSeq.gtf.gz](http://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/genes/hg38.ncbiRefSeq.gtf.gz) contains the RefSeq annotation for hg38 in [GFT format](http://www.genome.ucsc.edu/FAQ/FAQformat.html#format4)
......@@ -46,7 +68,7 @@ Does the number of *3UTR* match the number of *5UTR* ?
How many transcripts does the gene *CCR7* have ?
## Regular expression
# Regular expression
When you do a loot text search, you will encounter regular expression (regexp), which allow you to perform fuzzy search. To run `grep` in regexp mode you can use the switch `-E`
......@@ -68,7 +90,7 @@ There are different special characters in regexp, but you can use `\` to escape
gzip -dc hg38.ncbiRefSeq.gtf.gz | head | grep -E "\."
```
### Character classes and alternatives
## Character classes and alternatives
There are a number of special patterns that match more than one character. You’ve already seen `.`, which matches any character apart from a newline. There are four other useful tools:
......@@ -89,7 +111,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | head | perl -E "\d\d[A-Z]\d"
</p>
</details>
### Anchors
## Anchors
By default, regular expressions will match any part of a string. It’s often useful to *anchor* the regular expression so that it matches from the start or end of the string. You can use
......@@ -106,7 +128,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | head | grep -E "c"
gzip -dc hg38.ncbiRefSeq.gtf.gz | head | grep -E "^c"
```
### Repetition
## Repetition
The next step up in power involves controlling how many times a pattern matches
......@@ -143,7 +165,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | grep -E "transcript\s.*gene_id\s\"\S{16,}\";"
</p>
</details>
### Grouping and back references
## Grouping and back references
You can group match using `()`, for example the following regexp match doublet of *12* .
......@@ -170,7 +192,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | head | sed -E 's|ncbiRefSeq(.*)(transcript_id
</details>
Regexp can be very complexe see for example [a regex to validate an email on starckoverflow](https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression/201378#201378). When you start you can always use for a given regexp to a more experienced used (just give him the kind of text you want to match and not match). You can test your regex easily with the [regex101 website](https://regex101.com/).
## Sorting
# Sorting
GTF files should be sorted by chromosome, starting position and end position. But you can change that with the command `sort` to select the column to sort on you can use the option `-k n,n` where `n` is the column number.
......@@ -214,7 +236,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | head -n 10000 | sort -k 1,1 -k 4,4n -k 5,5n -c
## Field extractor
# Field extractor
Sometime rather than using complex regexp, we want to extract a particular column from a file. You can use the command `cut` to do that.
......@@ -233,7 +255,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | head | cut -f 2 -f 5 -d ";"
```
</p>
</details>
## Concatenation
# Concatenation
There are different tools to concatenate files from the command line `cat` for vertical concatenation and `paste` for horizontal concatenation.
......@@ -249,7 +271,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | head | paste - -
## Text editor
# Text editor
You often have access to different text editors from the common line, two of the most popular ones are `vim` and `nano`.
......@@ -271,8 +293,6 @@ You have 3 modes in `vim`:
If you want to learn more about `vim` you can start with the https://vim-adventures.com/ website. Once you master `vim` everything is faster but you will have to practice a loot.
In the next session, we are going to apply the logic of pipes and text manipulation to [batch processing.](./9_batch_processing.html)
> We have used the following commands:
>
> - `head` / `tail` to display head or tail of a file
......@@ -286,3 +306,5 @@ In the next session, we are going to apply the logic of pipes and text manipulat
> - `cat` / `paste` for concatenation
> - `nano` / `vim` for text edition
In the next session, we are going to apply the logic of pipes and text manipulation to [batch processing.](./9_batch_processing.html)
# Batch processing
---
title: Batch processing
author: "Laurent Modolo"
output:
rmdformats::downcute:
self_contain: true
use_bookdown: true
default_style: "light"
lightbox: true
css: "./www/style_Rmd.css"
---
```{r include = FALSE}
if (!require("fontawesome")) {
install.packages("fontawesome")
}
if (!require("klippy")) {
install.packages("remotes")
remotes::install_github("rlesur/klippy")
}
library(fontawesome)
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(comment = NA)
klippy::klippy(
position = c('top', 'right'),
color = "white",
tooltip_message = 'Click to copy',
tooltip_success = 'Copied !')
```
[![cc_by_sa](./img/cc_by_sa.png)](http://creativecommons.org/licenses/by-sa/4.0/)
......@@ -26,7 +56,7 @@ You can also use the `||` to manage errors and run `CMD2` if `CMD1` failed.
CMD1 || CMD2
```
## Executing list of commands
# Executing list of commands
The easiest option to execute list of command is to use `xargs`. `xargs` reads arguments from **stdin** and use them as argument for a command. In UNIX systems the command `echo` send string of character into **stdout**. We are going to use this command to learn more about `xargs`.
......@@ -107,7 +137,7 @@ find /tmp/ -type d | xargs -t rm -R
</p>
</details>
## Writing `awk` commands
# Writing `awk` commands
`xargs` It is a simple solution for writing batch commands, but if you want to write more complex command you are going to need to learn `awk`. `awk` is a programming language by itself, but you don’t need to know everything about `awk` to use it.
......@@ -209,7 +239,7 @@ awk 'BEGIN {OFS = "\n"} {header = $0 ; getline seq ; getline qheader ; getline q
## Writing a bash script
# Writing a bash script
When you start writing complicated command, you may want to save them to reuse them later.
......@@ -238,7 +268,7 @@ echo "download and extraction complete"
</details>
### shebang
## shebang
In your first bash script, the only thing saying that your script is a bash script is its extension. But most of the time UNIX system doesn’t care about file extension, a text file is a text file.
......@@ -275,7 +305,7 @@ Now you can execute your script with the command:
Congratulations you wrote your first program !
### PATH
## PATH
Where did they `/usr/bin/env` find the information about your bash ? Why did we have to write a `./` before our script if we are in the same folder ?
......@@ -347,7 +377,7 @@ You can check the result of your command with `echo $PATH`
Try to call your `download_hg38.sh` from anywhere on the file tree. Congratulation you installed your first UNIX program !
### Arguments
## Arguments
You can pass argument to your bash scripts, writing the following command:
......@@ -377,7 +407,6 @@ echo "Values of all the arguments: $@"
And you can try to call it with some arguments !
In the next session, we are going to learn how to execute command on other computers with [ssh.](./10_network_and_ssh.html)
> We have used the following commands:
>
......@@ -389,3 +418,5 @@ In the next session, we are going to learn how to execute command on other compu
> - `shebang` to specify the language of a script
> - `PATH` to install script
In the next session, we are going to learn how to execute command on other computers with [ssh.](./10_network_and_ssh.html)
......@@ -15,42 +15,45 @@ all: public/index.html \
public/github-pandoc.css: github-pandoc.css
cp github-pandoc.css public/github-pandoc.css
cp -R img public/
cp *.Rmd public/
cp -R www public/
public/index.html: index.md github-pandoc.css
pandoc -s -c github-pandoc.css index.md -o public/index.html
public/1_understanding_a_computer.html: 1_understanding_a_computer.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 1_understanding_a_computer.md -o public/1_understanding_a_computer.html
public/1_understanding_a_computer.html: 1_understanding_a_computer.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("1_understanding_a_computer.Rmd")'
public/2_using_the_ifb_cloud.html: 2_using_the_ifb_cloud.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 2_using_the_ifb_cloud.md -o public/2_using_the_ifb_cloud.html
public/2_using_the_ifb_cloud.html: 2_using_the_ifb_cloud.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("2_using_the_ifb_cloud.Rmd")'
public/3_first_steps_in_a_terminal.html: 3_first_steps_in_a_terminal.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 3_first_steps_in_a_terminal.md -o public/3_first_steps_in_a_terminal.html
public/3_first_steps_in_a_terminal.html: 3_first_steps_in_a_terminal.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("3_first_steps_in_a_terminal.Rmd")'
public/4_unix_file_system.html: 4_unix_file_system.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 4_unix_file_system.md -o public/4_unix_file_system.html
public/4_unix_file_system.html: 4_unix_file_system.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("4_unix_file_system.Rmd")'
public/5_users_and_rights.html: 5_users_and_rights.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 5_users_and_rights.md -o public/5_users_and_rights.html
public/5_users_and_rights.html: 5_users_and_rights.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("5_users_and_rights.Rmd")'
public/6_unix_processes.html: 6_unix_processes.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 6_unix_processes.md -o public/6_unix_processes.html
public/6_unix_processes.html: 6_unix_processes.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("6_unix_processes.Rmd")'
public/7_streams_and_pipes.html: 7_streams_and_pipes.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 7_streams_and_pipes.md -o public/7_streams_and_pipes.html
public/7_streams_and_pipes.html: 7_streams_and_pipes.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("7_streams_and_pipes.Rmd")'
public/8_text_manipulation.html: 8_text_manipulation.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 8_text_manipulation.md -o public/8_text_manipulation.html
public/8_text_manipulation.html: 8_text_manipulation.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("8_text_manipulation.Rmd")'
public/9_batch_processing.html: 9_batch_processing.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 9_batch_processing.md -o public/9_batch_processing.html
public/9_batch_processing.html: 9_batch_processing.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("9_batch_processing.Rmd")'
public/10_network_and_ssh.html: 10_network_and_ssh.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 10_network_and_ssh.md -o public/10_network_and_ssh.html
public/10_network_and_ssh.html: 10_network_and_ssh.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("10_network_and_ssh.Rmd")'
public/11_install_system_programs.html: 11_install_system_programs.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 11_install_system_programs.md -o public/11_install_system_programs.html
public/11_install_system_programs.html: 11_install_system_programs.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("11_install_system_programs.Rmd")'
public/12_virtualization.html: 12_virtualization.md github-pandoc.css
pandoc -s --toc -c github-pandoc.css 12_virtualization.md -o public/12_virtualization.html
public/12_virtualization.html: 12_virtualization.Rmd public/github-pandoc.css
cd public && Rscript -e 'rmarkdown::render("12_virtualization.Rmd")'
......@@ -4,6 +4,6 @@
All the materials are accessible at the following url:
[https://lbmc.gitbiopages.ens-lyon.fr/hub/formations/unix/](https://lbmc.gitbiopages.ens-lyon.fr/hub/formations/unix/)
[https://can.gitbiopages.ens-lyon.fr/unix-command-line/](https://can.gitbiopages.ens-lyon.fr/unix-command-line/)
You can join us on the dedicated matrix channel (ask [laurent.modolo@ens-lyon.fr](mailto:laurent.modolo@ens-lyon.fr))
This diff is collapsed.
img/SSD.jpeg

156 KiB

img/hdd.png

1.35 MiB

img/ram.png

369 KiB