Professional Documents
Culture Documents
presents
Bytes && Bites
on
There are small differences even within bash (shell) between the MacOS implementation (based on
UNIX BSD) and the linux (GNU) version of it, but it will not be an issue for this workshop).
● If you have windows, please install MOBAXterm
(https://mobaxterm.mobatek.net/)
Basic Commands 101
● Which user am I using?: ● See what’s in the file:
>whoami >less test
● What shell are we in?: >cat test
>echo $SHELL ● Create a directory
● Where am I? >mkdir dir1
>pwd ● Move files (note file is moved into a directory)
● How can I move from one directory to another: >mv test dir1
>cd <directory_name> >ls -l dir1
● Change to directory one level up.. ● Copy files
>cd .. >cp dir1/test .
● Change back to home directory .. >ls -l
>cd >ls -l dir1
● List files .. ● Removing a directory
>ls >mkdir dir2
● Listing, longer form with more details.. >rmdir dir2
>ls -l >rmdir dir1
● Create an “empty file”: ● Cannot remove dir1! Try the following:
>touch test >rm -r dir1
Basic Commands 101 (Cont)
● Moving a directory (moving is renaming!): Some fun with the terminal:
>mkdir dir1 >telnet towel.blinkenlights.nl
>mv dir1 dir2 >fortune
>mv dir2/dir1 /tmp/dir3
● What time is it Something useful:
>date >pwgen
● What is this file? >factor 169
>file test >curl wttr.in/Boston
>file dir1 >for i in {1..9}; do for j in $(seq 1 $i); do echo -ne $i×
>file /usr/bin/bash $j=$((i*j))\\t; done; echo;done
>file
● Copying multiple files
>touch test1 test2 test3
>cp test* dir2
● What does a command do:
>man cat
>man less
Basic Commands 101 (Cont)
● Man is your friend! Ask for help!
● What are flags/options on commands?
ls -l vs ls
rm vs rm -r
● Multiple editors: pico, nano, vim, emacs, etc.
● We will concentrate on vim. Some fun references:
○ https://www.openvim.com/
○ https://vim-adventures.com/
● vi vs vim
● vim has two modes: normal mode and insert mode
○ When you open a file with vim, you are in the normal mode. → Command mode
○ To change to insert mode: press i (lower case letter i) → Input text
○ Leave the insert mode: press the escape key esc
○ To leave a vim session without saving, go to normal mode and : press :q!
Vimtutor
● Vim ships with its own tutorial. If you type “vimtutor” at
the cursor, you will be in the tutorial.
○ Work through lesson 1 in vimtutor
○ Once we are done with lesson 1, we will create a
simple program (bash script) and run it.
Bash tutorials
https://linuxconfig.org/bash-scripting-tutorial-for-beginners
https://ryanstutorials.net/bash-scripting-tutorial/