The idea at this point is to make them comfortable with working in the terminal. When programming foundations start, it will pay off.
Base material:
Session 1
- File System
- Draw on board the tree (root > folder > more folders etc.)
- They have been creating this through UI (mouse till now)
- Terminal vs Shell
- Commands:
pwdlscd- explain:
cd ..andcd ~(~ is home, not root)
- explain:
mkdir- when they try to make multiple directories using one command each, show them
mkdir d1 d2 d3(faster than UI, they can start to see the value!) - Also, what if "d1 d2" should be file name, need to wrap in quotes.
- when they try to make multiple directories using one command each, show them
touchcatecho- Then combine echo with
>:echo "Hello World" > file.txt>>for append
- Then combine echo with
cpmv: show both move and rename with thisrmrmdir
Practice in between, ask them to create this structure using terminal commands they just learned:
Frappeverse
-------> photos
--------------> mumbai
----------------------> all.txt
-------> blog
-------------> <your-name>.txt
Session 2 <Practice with TAs>
Make them run commands on their computers (by Shivam)
Session 3
historyTabCompletions and Up Arrow Key for navigating through historygrep(the very basics) (take an example where the file contains multiple lines and occurrences of the word)
grep apple fruits.txt
- Command anatomy:
- e.g.
cp hello.txt backup/ command argument argument
- e.g.
- Flags
- e.g.
ls -lls -a(good time to make them see the difference that justlswill not show hidden (i.e. starting with a.) files and folders.
- e.g.
wc(stands for word count):
wc fruits.txt # 5 14 65 story.txt
wc -l fruits.txt # 5 story.txt
In the above, 5 is the number of lines, 14 is the number words, and 65 is the number of bytes in the given file(s). If -l option is given, only number of lines are printed.
man(manual pages) and--help- show for
wcetc. - they should be able to at least skim
- show for
- Wildcards
- e.g. list all
jpgimages in a file, all files starting with the letterpls *.jpgandls p*
- then expand to show how the wildcards are not just in
lsbut can be used to carry out copy, move etc.- move all
jpgimages toimages/folder etc. - e.g.
math_1.txt math_2.txt math_3.txt cs_1.txt cs_2.txt cs_3.txtmove math notes tomath/folder and cs notes tocs/folder.
- move all
- e.g. list all
Session 4 <Practice with TAs>
Practice with TAs.
Session 5
headandtail- head / tail by default 10 lines
head -n 5first 5 lines, with tail last 5 lines.- show examples
- (important to understand) redirection
- analogy of redirecting someone from where he was actually "directed" towards
- it was going to come on screen, but we asked the shell program to redirect it to some file instead
- Show if "ls >> list.txt", list.txt will get auto created if not exists, don't have to touch.
- (important to understand) pipe
- Again analogy to actual pipe connecting different chambers (e.g. water treatment plan) where each chamber does some mixing and the contents are forwarded to the next output pipe
- Take examples and make them practice:
$ ls | grep "apple" # list of files/dir that have apple in their name
$ history | tail -n 50 | grep "mkdir" > commands.txt
Good opportunity to give textual questions and see if they can breakdown the problem and chain the commands to get it done.
Last updated 3 weeks ago