Unverified Commit 1d4bc5ee authored by Todor Kondic's avatar Todor Kondic
Browse files

Add shell dir and adapt to shell practical

parent 26838e0d
# Aims of the Tutorial
* Connect to a GNU/Linux server
+ SSH, a de-facto standard for secure communication
<!-- .element: class="fragment" -->
+ For Windows users
- [MobaXterm][1] (_recommended by R3_)
- [PuTTY][2], simple, ugly, but efficient and open source and does only SSH
* Gain Familiarity With the Unix Shell
- And hint at ways it can be harnessed to give great power to the
user
<!-- .element: class="fragment" -->
+ For Mac and GNU/Linux users, OpenSSH command line client
<!-- .element: class="fragment" -->
<!-- .element: class="fragment" -->
* Explore how to use the shell effectively
* We will use bash which is (almost) universaly present
- Steve Jobs did not like the license, but ...
```shell
brew install bash
```
<!-- .element: class="fragment" -->
* Connect to a GNU/Linux server
+ Using SSH, a de-facto standard for secure communication
<!-- .element: class="fragment" -->
<!-- .element: class="fragment" -->
<!-- .element: class="fragment" -->
[1]: https://mobaxterm.mobatek.net/download-home-edition.html
[2]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
<!-- <iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/A-HIlNGczgU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> -->
......@@ -11,7 +11,8 @@
<!-- .element: class="fragment" -->
+ GNU/Linux user since [Debian Woody][5] (ca 2002)
+ Arrived as a seven CD set from a small computer shop from the [Getting Debian][6]
+ Arrived as a seven CD set from a small computer shop from the
list of international vendors at [Getting Debian][6]
<!-- .element: class="fragment" -->
......
......@@ -3,6 +3,11 @@
{ "filename" : "intro_first.md"},
{ "filename" : "intro_beforewebegin.md"},
{ "filename" : "intro_aim.md"},
{ "filename" : "shell.md"},
{ "filename" : "shell/start.md"},
{ "filename" : "shell/effective-cmd-editing.md"},
{ "filename" : "shell/cp-mv.md"},
{ "filename" : "shell/rm.md"},
{ "filename" : "ssh_intro.md"},
{ "filename" : "ssh_intro_2.md"},
{ "filename" : "ssh_intro_3.md"},
......
# The Barrier between the Human and the Machine
<div class="multicol">
<div class="col" data-markdown>
* What is a shell?
- Omnipresent user interface
<!-- .element: class="fragment" -->
- It interprets commands given by the user
<!-- .element: class="fragment" -->
- It is heavily keyboard based
<!-- .element: class="fragment" -->
<!-- .element: class="fragment" -->
* Shell runs within a terminal application
- In ancient times, these were actual pieces of hardware
<!-- .element: class="fragment" -->
- Today, a program that echoes user input and displays command results
<!-- .element: class="fragment" -->
<!-- .element: class="fragment" -->
* How to access it?
- **GNU/Linux systems:**
- Depends on the desktop interface (of which there are many)
- Access from a `Start`-like menu, or a `Win`-key search as
*terminal*, or *console*
- if all else fails, `Ctrl` + `Alt` + `F[2-6]`
<!-- .element: class="fragment" -->
- **Windows:** [MobaXterm][1] which you hopefully installed
<!-- .element: class="fragment" -->
- **Mac:** Built-in terminal; *Spotlight* search for *terminal*
<!-- .element: class="fragment" -->
<!-- .element: class="fragment" -->
</div>
<div class="col" data-markdown>
<img src="variae/figs/shell/3270.jpg" width="90%" />
<!-- .element: class="fragment" -->
</div>
</div>
[terminal]: variae/figs/shell/3270.jpg "IBM 3270"
[1]: https://mobaxterm.mobatek.net/download-home-edition.html
# File Explorer: Copy(cp), Move(mv) and Remove(rm) File Operations
```console
$ mkdir linux-practical-03
$ cp linux-practical-01/pr1-hello-world.txt linux-practical-03/pr3-hello-world.txt # cp arg1 arg2: copy file arg1 to file arg2
$ mkdir linux-practical-03/dump
$ cp -R linux-practical-01 linux-practical-03/dump # Copy the entire content of linux-practical-01
$ # to dump subdirectory of linux-practical-03
$ ls linux-practical-03/dump # Check if linux-practical-01 is there.
$ # Move one up in history, jump to the beginning of the line ('Ctrl'+'A'), then
$ # replace 'ls' with 'mv'
$ # From then on ...
$ mv linux-practical-03/dump linux-practical-03/dump2 # Congratulations, you just renamed dump to dump2.
$ ls linux-practical-03 # Check the content. The directory dump should not exist.
```
# Practical: Effective Command Line Editing
```console
$ # Move up the history list until 'mkdir linux-practical-01'.
$ # Move cursor using word motions 'Ctrl' + 'Left', or
$ # 'Ctrl' + 'Right' around the command to get the feel for word motions.
$ # Move cursor using begin ('Ctrl' + 'A') and end ('Ctrl' + 'E')
$ # motions to the beginning and the end of the line.
$ mkdir linux-practical-02 # Based on the previous command + motions.
$ cd lin # TAB to complete, then TAB two times to list possible endings.
$ cd linux-practical-02 # Based on the previous completion.
$ # Move up the history list to mkdir subdir-01
$ mkdir subdir-02
$ # Move up the history to the touch subdir-01/a ... command.
$ # Replace 1 with 2 using 'Ctrl' + 'A' and word motions.
$ touch subdir-02/a subdir-02/b subdir-02/c
$ history 10 # Lists last ten commands.
$ cd
```
<!-- * Motions -->
<!-- - `Left` and `Right` arrow move one character left, or right -->
<!-- - `Ctrl` + `Left`, or `Right` move left, or right for one word -->
<!-- - `Ctrl` + `A`, or `E` move to the beginning, or the end of the line -->
<!-- - `Up` and `Down` move through history entries -->
<!-- - `TAB` completes -->
# File Explorer: Copy(cp), Move(mv) and Remove(rm) File Operations
* Removing files and directories.
```console
$ rm linux-practical-03/pr3-hello-world.txt # Deletes the file.
$ # History, one up then adapt the command into
$ cd linux-practical-03
$ ls # Check if it is indeed deleted.
$ rm -R dump2 # Recursively remove directory dump2 and all of its contents.
$ history 10 # Just to remind yourself what you did in last ten steps.
$ cd
```
# File Explorer: The Immediate Surroundings
* Command line
- **Command prompt:** Non-editable; May provide contextual information
- **Command area:** Typed commands are shown here
- **RETURN or ENTER:** Pressing this key will execute the command
```shell
prompt$ command arg1 arg2 ...
```
<!-- .element: class="fragment" -->
```console
$ pwd # Displays the absolute path to the current dirrectory.
$ ls # List contents of the current directory.
$ mkdir linux-practical-01 # Create a new directory.
$ cd linux-practical-01 # Switch to a different directory.
$ touch pr1-hello-world.txt # Create a new and empty file.
$ mkdir subdir-01 # Create another directory.
$ touch subdir-01/a subdir-01/b subdir-01/c # Create multiple empty files.
$ ls subdir-01 # List contents of directory.
$ mkdir -p subdir-02/dir-X/dir-Y/dir-Z # Create a nested directory under the path.
$ ls subdir-02/dir-X # Confirm the directory dir-Y has been created.
$ history # Lists the commands executed so far.
$ cd
```
<!-- .element: class="fragment" -->
<!-- * Concepts -->
<!-- - Files and directories -->
<!-- - Paths -->
<!-- - Importance of quoting -->
<!-- - History -->
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment