diff --git a/.gitignore b/.gitignore index 888590f54820659953ec9d68d8a66d463c973409..d5ed92c7db20c07b614a861c561a1227731447a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ *.html .DS_Store .Rproj.user + +/.quarto/ +/_book/ +*_cache/ + diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f387292e0811a22f41d6e3b2233986704f49bdb4..42835800659e2c14f22967f8828c2167b3d9150f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,14 @@ -# This file is a template, and might need editing before it works on your project. -# Full project: https://gitlab.com/pages/plain-html - pages: stage: deploy - image: carinerey/r_for_beginners + image: rocker/tidyverse script: - - mkdir -p public/ - - cp -R img public/ - - make + - apt update && apt install -y libxt6 + - quarto -v + - | + quarto render + mkdir public + cp -r _book/* public/ + interruptible: true artifacts: paths: - public diff --git a/10_network_and_ssh.Rmd b/10_network_and_ssh.Rmd index 8d40669ccaf9a7274576255abff879f105547c88..327645ba9fda17a4f9b7f20c3aba0237e27a0497 100644 --- a/10_network_and_ssh.Rmd +++ b/10_network_and_ssh.Rmd @@ -1,36 +1,20 @@ --- 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 !" -) ``` -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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: Learn basics of ssh connection in GNU/Linux @@ -38,11 +22,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. @@ -50,7 +34,7 @@ If you try to call someone, who is already in a phone conversation, the line wil  -## 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. @@ -60,7 +44,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). @@ -68,7 +52,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: @@ -91,7 +75,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). @@ -104,13 +88,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.  -## 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 communicating over an IP network. @@ -121,7 +105,7 @@ The **Transmission Control Protocol** (**TCP**) is one of the main [protocols](h - includes traffic congestion control - Heavyweight (loots of checks) -## **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. @@ -131,7 +115,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). @@ -157,7 +141,7 @@ Here is 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. @@ -175,25 +159,25 @@ ps -el | grep "ssh" SSH uses [Public-key cryptography (or asymmetric cryptography](https://en.wikipedia.org/wiki/Public-key_cryptography)), to secure its 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.  -## 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).  -## 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 @@ -201,7 +185,7 @@ Can be used to share public keys (see [Diffie-Hellman)](https://fr.wikipedia.org  -# 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. @@ -259,7 +243,7 @@ sudo passwd student Give the password and your IP to another member of your choice (`ip address show`). -# SSH client +## SSH client To connect of an SSH server you can use the following command: @@ -277,7 +261,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. @@ -315,11 +299,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 files from your computer to the ssh sever: @@ -337,7 +321,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. @@ -349,13 +333,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 @@ -369,7 +353,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`. diff --git a/11_install_system_programs.Rmd b/11_install_system_programs.Rmd index 5b57f0634909205e209cbd1ce95040f89a380a0e..983bb53761b16c07e3d4ef9c95dfeea200fcdb43 100644 --- a/11_install_system_programs.Rmd +++ b/11_install_system_programs.Rmd @@ -1,36 +1,20 @@ --- 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 !') - ``` -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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: Learn how to install programs in GNU/Linux @@ -38,7 +22,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 managers](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**). @@ -69,7 +53,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`). @@ -87,7 +71,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`. @@ -105,7 +89,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** @@ -141,7 +125,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: @@ -168,7 +152,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. @@ -184,7 +168,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. diff --git a/12_virtualization.Rmd b/12_virtualization.Rmd index e6e442c55ac844a29a5aa3c7e7b37b7ae0a88062..935ed75599a8b8f1dc5367bc2f1d3e37b7a8c4f0 100644 --- a/12_virtualization.Rmd +++ b/12_virtualization.Rmd @@ -1,36 +1,20 @@ --- 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 !') - ``` -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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: Learn how to build virtual images or container of a system @@ -46,21 +30,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: @@ -130,7 +114,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. @@ -194,7 +178,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` @@ -226,7 +210,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: diff --git a/1_understanding_a_computer.Rmd b/1_understanding_a_computer.Rmd index 2e03d5448962032714c9f941f875fd005a73f441..3cc49f7ee8d8e35848719eb15e5c7866738c806c 100644 --- a/1_understanding_a_computer.Rmd +++ b/1_understanding_a_computer.Rmd @@ -1,33 +1,15 @@ --- 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" --- ```{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/"> @@ -36,48 +18,48 @@ klippy::klippy( Objective: understand the relations between the different components of a computer -# Which parts are necessary to define a computer ? +## Which parts are necessary to define a computer ? -# Computer components +## Computer components -## CPU (Central Processing Unit) +### CPU (Central Processing Unit) {width=100%} -## Memory +### Memory -### RAM (Random Access Memory) +#### RAM (Random Access Memory) {width=100%} -### HDD (Hard Disk Drive) / SSD (Solid-State Drive) +#### HDD (Hard Disk Drive) / SSD (Solid-State Drive) {width=100%} {width=100%} -## Motherboard +### Motherboard {width=100%} -## GPU (Graphical Processing Unit) +### GPU (Graphical Processing Unit) {width=100%} -## Alimentation +### Alimentation {width=100%} --- -# Computer model: universal Turing machine +## Computer model: universal Turing machine {width=100%} --- -# As simple as a Turing machine ? +## As simple as a Turing machine ? -{width=100%} +{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. @@ -86,7 +68,7 @@ Objective: understand the relations between the different components of a comput --- -# Basic Input Output System (BIOS) +## Basic Input Output System (BIOS) > Used to perform hardware initialization during the booting process (power-on startup), and to provide runtime services for operating systems and programs. @@ -96,7 +78,7 @@ Objective: understand the relations between the different components of a comput --- -# Unified Extensible Firmware Interface (UEFI) +## Unified Extensible Firmware Interface (UEFI) Advantages: @@ -113,22 +95,22 @@ Disadvantages: --- -# Operating System (OS) +## Operating System (OS) > A system software that manages computer hardware, software resources, and provides common services for computer programs. - The first thing loaded by the BIOS/UEFI - The first thing on the tape of a Turing machine -## Kernel +### 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){width=100%} +{width=100%} --- -# UNIX +## UNIX > Unix is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, @@ -142,7 +124,7 @@ The ones you are likely to encounter: The philosophy of UNIX is to have a large number of small software which do few things but to them well. -# GNU/Linux +## GNU/Linux 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/). diff --git a/2_using_the_ifb_cloud.Rmd b/2_using_the_ifb_cloud.Rmd index 8a6c5a52c2d78de8a673f630e5b9c768868d4dbc..d663affc27813bb63f8f33e3dcef33677a29ee97 100644 --- a/2_using_the_ifb_cloud.Rmd +++ b/2_using_the_ifb_cloud.Rmd @@ -1,54 +1,28 @@ --- 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" --- ```{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> -[](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 (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 (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%;" /> 3. Then click on  4. Use the **Incremental search field** to select your identity provider (CNRS / ENS de Lyon / etc.) @@ -58,7 +32,7 @@ Instead of working on your computer where you don't have an Unix-like OS or have 8. Click on  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 2022 appliance +## Starting the LBMC Unix 2022 appliance 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  button after login with your account. @@ -82,7 +56,7 @@ You will need to start this appliance at the start of each session of this cours The  symbol indicates that your appliance is starting. -# Accessing the LBMC Unix 2022 +## 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 diff --git a/3_first_steps_in_a_terminal.Rmd b/3_first_steps_in_a_terminal.Rmd index 607e08e6521ba55ceebb1508c731bf8127d7b04c..77380cf6b756d4923aec39b68111f5eb352d9159 100644 --- a/3_first_steps_in_a_terminal.Rmd +++ b/3_first_steps_in_a_terminal.Rmd @@ -1,42 +1,21 @@ --- 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" --- ```{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> - -[](http://creativecommons.org/licenses/by-sa/4.0/) - Objective: learn to use basic terminal command Congratulations you are now connected on your VM ! @@ -49,34 +28,35 @@ 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. To simplify the shell executes the following infinite loop: + 1. read a line 2. translate this line as a program execution with its parameters 3. launch the corresponding program with the parameters 3. wait for the program to finish 4. Go back to 1. -When you open a terminal on an Unix-like OS, you will have a **prompt** displayed: it can end with a **$** or a **%** character depending on your configuration. As long as you see your prompt, it means that you are in step **1.**, if no prompt is visible, you are in step **4.** or you have set up a very minimalist configuration for your shell. +When you open a terminal on an Unix-like OS, you will have a **prompt** displayed: it can end with a `$` or a `%` character depending on your configuration. As long as you see your prompt, it means that you are in step **1.**, if no prompt is visible, you are in step **4.** or you have set up a very minimalist configuration for your shell. <img src="./img/prompt.png" alt="prompt" style="zoom:150%;" /> -The blinking square or vertical bar represents your **cursor**. Shell predates graphical interfaces, so most of the time you won’t be able to move this cursor with your mouse, but with the directional arrows (left and right). +The blinking square or vertical bar represents your **cursor**. Shell predates graphical interfaces, so most of the time you won’t be able to move this cursor with your mouse, but with the **directional arrows** (left and right). -On the IFB, your prompt is a **$** +On the IFB, your prompt is a `$`: ```sh etudiant@VM:~$ ``` -You can identify the following information from your prompt: **etudiant** is your login and **VM** is the name of your VM (**~** is where you are on the computer, but we will come back to that later). +You can identify the following information from your prompt: **etudiant** is your login and **VM** is the name of your VM (`~` is where you are on the computer, i.e. the current working directory, but we will come back to that later). 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: @@ -126,7 +106,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. diff --git a/4_unix_file_system.Rmd b/4_unix_file_system.Rmd index 3470a9263a50420a6f437a837e880db36e04e958..4de19a2e63e27fbd60d09e9c36168519e4cefdde 100644 --- a/4_unix_file_system.Rmd +++ b/4_unix_file_system.Rmd @@ -1,41 +1,21 @@ --- 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" --- ```{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> -[](http://creativecommons.org/licenses/by-sa/4.0/) - Objective: Understand how files are organized in Unix > On a UNIX system, everything is a file ; if something is not a file, it is a process. @@ -60,7 +40,7 @@ Every file can be accessed by an **absolute path** starting at the root. Your us 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 is the list of file types: @@ -80,25 +60,25 @@ 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. 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 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 ? -## `/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. @@ -108,7 +88,7 @@ What is the difference between `/bin` and `/usr/bin` ? `/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. @@ -116,11 +96,11 @@ 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 @@ -132,7 +112,7 @@ Using `less` can you visualize the content of the file `urandom` ? What about th 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... @@ -150,11 +130,11 @@ What is the type of the file `autofs.fifo-var-autofs-ifb` in the `run` folder ? 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 ? @@ -166,7 +146,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 @@ -218,7 +198,7 @@ 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...) diff --git a/5_users_and_rights.Rmd b/5_users_and_rights.Rmd index e859b550329ae17aa1534e1e63e0d6756cb10f48..c4339b3923ef58a1cda4f0c835f7eb6a7288571b 100644 --- a/5_users_and_rights.Rmd +++ b/5_users_and_rights.Rmd @@ -1,36 +1,20 @@ --- 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" --- ```{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 !') - ``` -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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 how rights works in GNU/Linux @@ -48,7 +32,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: @@ -153,7 +137,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: @@ -187,7 +171,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. @@ -225,7 +209,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` @@ -252,7 +236,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` @@ -280,7 +264,7 @@ 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, 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**) diff --git a/6_unix_processes.Rmd b/6_unix_processes.Rmd index a2fa43f28acfcbeeb369f221219336090a88e5d1..999f9ab7b3ffb2c051355a444f0bea7b73180b9a 100644 --- a/6_unix_processes.Rmd +++ b/6_unix_processes.Rmd @@ -1,38 +1,20 @@ --- 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 - -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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 how process works in GNU/Linux @@ -48,7 +30,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 @@ -95,7 +77,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. @@ -142,7 +124,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. @@ -186,7 +168,7 @@ A process with a **PPID** of **1** is called a **daemon**, daemons are processes 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 ? @@ -226,7 +208,7 @@ Bring the 2nd `htop` to the foreground. Put it back to the background with `ctrl The command `bg` allows 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` processes like that in the background. diff --git a/7_streams_and_pipes.Rmd b/7_streams_and_pipes.Rmd index a0ccd7fa51b1c037f03af88da4c6ae7802d556eb..f86a5ce80edd3769765ab1468e976494d5f618e8 100644 --- a/7_streams_and_pipes.Rmd +++ b/7_streams_and_pipes.Rmd @@ -1,36 +1,20 @@ --- 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" --- ```{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 !') - ``` -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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 function of streams and pipes in Unix systems @@ -60,7 +44,7 @@ cat .bashrc -# Streams manipulation +## Streams manipulation You can use the `>` character to redirect a flux toward a file. The following command makes a copy of your `.bashrc` files. @@ -123,7 +107,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 `| ` diff --git a/8_text_manipulation.Rmd b/8_text_manipulation.Rmd index 09b76eec9a2f8b3f5d638f38254d798429eee9ce..08c18ebccbef806964210045543413069a0ced36 100644 --- a/8_text_manipulation.Rmd +++ b/8_text_manipulation.Rmd @@ -1,42 +1,26 @@ --- 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" --- ```{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 !" -) ``` -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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: Learn simple ways to work with text file in Unix One of the great things with command line tools is that they are simple and fast. Which means that they are great for handling large files. And as bioinformaticians you have to handle large files, 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) @@ -68,7 +52,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 expressions (regexp), which allow you to perform fuzzy search. To run `grep` in regexp mode you can use the switch. `-E` @@ -90,7 +74,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: @@ -111,7 +95,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 @@ -128,7 +112,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 @@ -165,7 +149,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* . @@ -192,7 +176,7 @@ gzip -dc hg38.ncbiRefSeq.gtf.gz | head | sed -E 's|ncbiRefSeq(.*)(transcript_id </details> Regexp can be very complex 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. @@ -236,7 +220,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. @@ -255,7 +239,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. @@ -271,7 +255,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`. diff --git a/9_batch_processing.Rmd b/9_batch_processing.Rmd index 8d817ce23a7b29906c69dda3269ef4517dccd92d..5ecaf3a9a6aaa40f250da688cf4fb440cf363eb5 100644 --- a/9_batch_processing.Rmd +++ b/9_batch_processing.Rmd @@ -1,36 +1,20 @@ --- 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 !') - ``` -[](http://creativecommons.org/licenses/by-sa/4.0/) +<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: Learn basics of batch processing in GNU/Linux @@ -56,7 +40,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 arguments 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`. @@ -137,7 +121,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. @@ -239,7 +223,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. @@ -268,7 +252,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. @@ -277,13 +261,13 @@ To tell the system that your text file is a bash script you need to add a **sheb For example, for a bash script in a system where `bash` is installed in `/bin/bash` the **shebang** is: ```bash -#!/bin/bash +##!/bin/bash ``` When you are not sure `which`is the path of the tools available to interpret your script, you can use the following shebang: ```bash -#!/usr/bin/env bash +##!/usr/bin/env bash ``` You can add a **shebang** to your script and add it the e**x**ecutable right. @@ -305,7 +289,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 ? @@ -377,7 +361,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: @@ -398,7 +382,7 @@ Means that from within the script: You can write the following `variables.sh` script in your `scripts` folder: ```sh -#!/bin/bash +##!/bin/bash echo "Name of the script: $0" echo "Total number of arguments: $#" diff --git a/_quarto.yml b/_quarto.yml new file mode 100644 index 0000000000000000000000000000000000000000..bbd0e8db3ff2f96a8143d80da48daa00fa184f9b --- /dev/null +++ b/_quarto.yml @@ -0,0 +1,42 @@ +project: + type: book + +book: + title: "UNIX command line" + author: + - "Laurent Modolo" + date: "2023-10-09" + chapters: + - index.md + - 1_understanding_a_computer.Rmd + - 2_using_the_ifb_cloud.Rmd + - 3_first_steps_in_a_terminal.Rmd + - 4_unix_file_system.Rmd + - 5_users_and_rights.Rmd + - 6_unix_processes.Rmd + - 7_streams_and_pipes.Rmd + - 8_text_manipulation.Rmd + - 9_batch_processing.Rmd + - 10_network_and_ssh.Rmd + - 11_install_system_programs.Rmd + - 12_virtualization.Rmd + body-footer: "License: Creative Commons [CC-BY-SA-4.0](http://creativecommons.org/licenses/by-sa/4.0/).<br>Made with [Quarto](https://quarto.org/)." + navbar: + search: true + right: + - icon: git + href: https://gitbio.ens-lyon.fr/can/unix-command-line + text: Sources + +# bibliography: references.bib + +format: + html: + theme: + light: flatly + dark: darkly + +execute: + cache: true + + \ No newline at end of file diff --git a/index.md b/index.md index 8324b5394857f16b72f9dcd35862669ecc9750fb..2aace675a46e167fa816afec4896030808949b3b 100644 --- a/index.md +++ b/index.md @@ -1,8 +1,4 @@ ---- -title: # Unix / command line training course ---- - -# Unix / command line training course +## Unix / command line training course {.unnumbered} 1. [Understanding a computer](./1_understanding_a_computer.html) 2. [Using the IFB cloud](./2_using_the_ifb_cloud.html)