class: title-slide count: false .title[ # 05 - Terminal ] .subtitle[ ## Open Science Tools ] .author[ ### Claudio Zandonella & Davide Massidda ] .institute[ ] --- class: center, middle, inverse # Step V: Terminal --- # Terminal -- <img src="images/06-terminal/terminal-meme.jpeg" width="45%" style="display: block; margin: auto;" /> --- # Terminal <img src="images/06-terminal/terminal.png" width="60%" style="display: block; margin: auto;" /> -- .center[*“When the going gets tough the terminal gets opening”*] --- # Terminal .pull-left-60[ #### Definitions .li-small[ {{content}} ] ] .pull-right-40[ ] -- - **Command Line Interface (CLI)**<br>The text-based interface,<br>opposite of Graphical User Interface (GUI) <br> {{content}} -- - **Terminal (or Console)**<br>The graphical window with a command-line interface<br>that allows us to interact with the shell <br> {{content}} -- - **Shell**<br>The interpreter that processes the commands<br>and communicates with the Operating System --- # Terminal .pull-left-60[ #### Definitions .li-small[ - **Command Line Interface (CLI)**<br>The text-based interface,<br>opposite of Graphical User Interface (GUI) <!-- --> - **Terminal (or Console)**<br>The graphical window with a command-line interface<br>that allows us to interact with the shell <!-- --> - **Shell**<br>The interpreter that processes the commands<br>and communicates with the Operating System <br> .center[*Programming Language vs Command Language*] ] ] .pull-right-40[ {{content}} ] -- #### Different Shells --- # Terminal .pull-left-60[ #### Definitions .li-small[ - **Command Line Interface (CLI)**<br>The text-based interface,<br>opposite of Graphical User Interface (GUI) <!-- --> - **Terminal (or Console)**<br>The graphical window with a command-line interface<br>that allows us to interact with the shell <!-- --> - **Shell**<br>The interpreter that processes the commands<br>and communicates with the Operating System <br> .center[*Programming Language vs Command Language*] ] ] .pull-right-40[ #### Different Shells .move-down-30[ <table class="table" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Shell Interpreter </th> </tr> </thead> <tbody> <tr grouplength="3"><td colspan="1" style="border-bottom: 1px solid;"><strong>Windows</strong></td></tr> <tr> <td style="text-align:left;padding-left: 2em;" indentlevel="1"> Command Prompt (CMD) </td> </tr> <tr> <td style="text-align:left;padding-left: 2em;" indentlevel="1"> PowerShell </td> </tr> <tr> <td style="text-align:left;padding-left: 2em;" indentlevel="1"> ... </td> </tr> <tr grouplength="4"><td colspan="1" style="border-bottom: 1px solid;"><strong>Unix System (macOS and Linux)</strong></td></tr> <tr> <td style="text-align:left;padding-left: 2em;" indentlevel="1"> sh (Bourne shell) </td> </tr> <tr> <td style="text-align:left;padding-left: 2em;" indentlevel="1"> Bash (Bourne again shell) </td> </tr> <tr> <td style="text-align:left;padding-left: 2em;" indentlevel="1"> Zsh (Z shell) </td> </tr> <tr> <td style="text-align:left;padding-left: 2em;" indentlevel="1"> ... </td> </tr> </tbody> </table> ] ] --- # Get Started -- .pull-left-40[ #### Prompt <img src="images/06-terminal/terminal.png" width="99%" style="display: block; margin: auto;" /> .code-size-12[ ```bash HOST_NAME:CURRENT_DIRECTORY USER_NAME$ ``` ] ] .pull-right-60[ ] --- # Get Started .pull-left-40[ #### Prompt <img src="images/06-terminal/terminal.png" width="99%" style="display: block; margin: auto;" /> .code-size-12[ ```bash HOST_NAME:CURRENT_DIRECTORY USER_NAME$ ``` ] ] .pull-right-60[ #### Commands .code-size-12[ ```bash Command [Options] Argument1 Argument2 ... # Examples ls -la ~/Desktop/my-project cp -r ~/Desktop/my-project/ ~/Document/my-project/ ``` ] .li-size-14[ .font-14[ - `Command` function name - `Options` obtain command specific behaviour - square brackets `[...]` indicate optional elements - single letters `-<letter/s>` (e.g., `-l`, `-a`, `-la`) - Full word `--<option-name>` (e.g., `--all`) - `Argument*`, separated by space (need to wrap words!) ] ] ] --- # Get Started .pull-left-40[ #### Prompt <img src="images/06-terminal/terminal.png" width="99%" style="display: block; margin: auto;" /> .code-size-12[ ```bash HOST_NAME:CURRENT_DIRECTORY USER_NAME$ ``` ] ] .pull-right-60[ #### Commands .code-size-12[ ```bash Command [Options] Argument1 Argument2 ... # Examples ls -la ~/Desktop/my-project cp -r ~/Desktop/my-project/ ~/Document/my-project/ ``` ] .li-size-14[ .font-14[ - `Command` function name - `Options` obtain command specific behaviour - square brackets `[...]` indicate optional elements - single letters `-<letter/s>` (e.g., `-l`, `-a`, `-la`) - Full word `--<option-name>` (e.g., `--all`) - `Argument*`, separated by space (need to wrap words!) ] ] .code-size-12[ ```bash Software Command [Options] Argument1 Argument2 ... # Example git push -u origin main docker build -t my-image:1.0.0 Desktop/my-project ``` ] ] --- # Get Started .pull-left-40[ #### Navigating Directories ] .pull-right-60[ ] --- # Get Started .pull-left-40[ #### Navigating Directories .li-small[ - `pwd` print working directory ] ] .pull-right-60[ #### .code-size-12[ ```bash $ pwd /Users/myname ``` ] ] --- # Get Started .pull-left-40[ #### Navigating Directories .li-small[ - `pwd` print working directory - `ls` list directory contents - `-l` long listing format - `-a` list all files (also hidden) ] ] .pull-right-60[ #### .move-down-60[ .code-size-12[ ```bash $ ls Applications Documents Library Desktop Downloads ``` ```bash $ ls -l Desktop/ drwxr-xr-x@ 17 claudio staff 23544 Dec 17 17:09 Courses drwxr-xr-x@ 17 claudio staff 14590 Dec 17 17:09 Presentations -rw-r--r-- 1 claudio staff 5928 Feb 3 14:41 Repot.pdf -rw-r--r--@ 1 claudio staff 160 Jan 18 11:10 TODO-list.txt ``` ] ] ] --- # Get Started .pull-left-40[ #### Navigating Directories .li-small[ - `pwd` print working directory - `ls` list directory contents - `-l` long listing format - `-a` list all files (also hidden) - `cd <directory>`<br>change directory ] ] .pull-right-60[ #### .move-down-170[ .code-size-12[ ```bash $ cd Desktop/Courses/Open-Science $ pwd /Users/myname/Desktop/Courses/Open-Science ``` ```bash $ cd ../../ $ pwd /Users/myname/Desktop ``` ] ] ] --- # Get Started .pull-left-40[ #### Navigating Directories .li-small[ - `pwd` print working directory - `ls` list directory contents - `-l` long listing format - `-a` list all files (also hidden) - `cd <directory>`<br>change directory ] #### Extra .li-small[ - `Tab` autocomplete / list options - `up/down keys` navigate history ] ] .pull-right-60[] --- # Get Started .pull-left-40[ #### Modifying Files ] .pull-right-60[] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory ] ] .pull-right-60[ #### .code-size-12[ ```bash $ mkdir my-project $ cd my-project $ pwd /Users/myname/my-project ``` ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file ] ] .pull-right-60[ #### .move-down-80[ .code-size-12[ ```bash $ touch README $ ls README ``` ] ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file - `cat <file>`<br>Print content on screen - `less <file>`<br>Visualize content on screen ] ] .pull-right-60[ #### .move-down-140[ .code-size-12[ ```bash $ cat README $ ``` ] ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file - `cat <file>`<br>Print content on screen - `less <file>`<br>Visualize content on screen - `echo <text>`<br>Print text on screen ] ] .pull-right-60[ #### .move-down-270[ .code-size-12[ ```bash $ echo "Hello World!" Hello World! ``` ] ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file - `cat <file>`<br>Print content on screen - `less <file>`<br>Visualize content on screen - `echo <text>`<br>Print text on screen ] #### Extra .li-small[ - `>` overwrites a file - `>>` appends to a file ] ] .pull-right-60[ #### .move-down-270[ .code-size-12[ ```bash $ echo "Hello World!" Hello World! $ echo "Hello World!" >> README ``` ```bash $ cat README Hello World! ``` ] ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file - `cat <file>`<br>Print content on screen - `less <file>`<br>Visualize content on screen - `echo <text>`<br>Print text on screen ] #### Extra .li-small[ - `>` overwrites a file - `>>` appends to a file ] ] .pull-right-60[ #### .li-small[ - `mv <file> <to>`<br>Move file ] .code-size-12[ ```bash $ mv ../Report.pdf . $ ls README Report.pdf ``` ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file - `cat <file>`<br>Print content on screen - `less <file>`<br>Visualize content on screen - `echo <text>`<br>Print text on screen ] #### Extra .li-small[ - `>` overwrites a file - `>>` appends to a file ] ] .pull-right-60[ #### .li-small[ - `mv <file> <to>`<br>Move file - `cp <file> <to>`<br>Copy file - `-r` recursive for directories ] .code-size-12[ ```bash $ cp Report.pdf Report-copy.pdf $ ls README Report-copy.pdf Report.pdf ``` ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file - `cat <file>`<br>Print content on screen - `less <file>`<br>Visualize content on screen - `echo <text>`<br>Print text on screen ] #### Extra .li-small[ - `>` overwrites a file - `>>` appends to a file ] ] .pull-right-60[ #### .li-small[ - `mv <file> <to>`<br>Move file - `cp <file> <to>`<br>Copy file - `-r` recursive for directories - `rm <file>`<br>Remove file - `-r` recursive for directories ] .code-size-12[ ```bash $ rm Report-copy.pdf $ ls README Report.pdf ``` ] ] --- # Get Started .pull-left-40[ #### Modifying Files .li-small[ - `mkdir <dir-name>`<br>Make directory - `touch <file-name>`<br>Create a blank file - `cat <file>`<br>Print content on screen - `less <file>`<br>Visualize content on screen - `echo <text>`<br>Print text on screen ] #### Extra .li-small[ - `>` overwrites a file - `>>` appends to a file ] ] .pull-right-60[ #### .li-small[ - `mv <file> <to>`<br>Move file - `cp <file> <to>`<br>Copy file - `-r` recursive for directories - `rm <file>`<br>Remove file - `-r` recursive for directories ] .move-down-120[ .li-small[ - `Ctrl + Shift + C` (or `Control + C` on macOS) interrupt the command ] ] ] --- # Terminal in RStudio -- .pull-left-50[ .move-up-30[ Open a new Terminal window ] <img src="images/06-terminal/new-terminal.png" width="65%" style="display: block; margin: auto;" /> <img src="images/06-terminal/terminal-panel.png" width="65%" style="display: block; margin: auto;" /> ] .pull-right-50[ .move-up-30[ {{content}} ] ] -- Select the default shell <img src="images/06-terminal/terminal-settings.png" width="90%" style="display: block; margin: auto;" /> --- class: inverse, center, middle # With great power comes great responsibility!! ## Moving to the next step...