The first class introduces the terminal shell, and they mainly focus on Bash since it is the default in most platform.
Brief
It is perfect for the beginners without any knowledge of shell. Starting from terminal basics to some basic commands in bash such as echo and ls, the class provides enough information for anyone to start to explore the shell system (I guess man is enough to start …).
After going through the video and texts, we still need to figure out how to use more commands in order to grasp the basics of temrinal. I guess the most important experience for me is to search only when you need it. There are tons of commands to know if we want them all, and each commands has tons of options to explore. It turns to be extremely boring for me if I learn by reading A-Z exhausitive reference of shell commands. If you want to know how to find a file, then you learn find, and if you need to change a batch of files’ names, you get to know for loop and probably sed.
Another thing that might be helpful is, there are always many ways to finish one target. If you don’t like the top answer from StackOverflow, maybe the second one or some comments might attract you.
Exercise
- Create a new directory called 
missingunder/tmp. 
1  | cd /tmp  | 
- Look up the 
touchprogram. Themanprogram is your friend. 
1  | man touch  | 
Here is a link about discussion
of how to use touch. Except create a new file, it can change the
timestep to accomplish interesting task.
- Use 
touchto create a new file calledsemesterinmissing. 
1  | touch semester  | 
- Write the following into that file, one line at a time:The first line might be tricky to get working. It’s helpful to know that
1
2
curl --head --silent https://missing.csail.mit.edu#starts a comment in Bash, and!has a special meaning even within
double-quoted (") strings. Bash treats single-quoted strings (')
differently: they will do the trick in this case. See the Bash
quoting
manual page for more information. 
1  | echo \#\!/bin/sh > semester  | 
What if we want to add these line at the beginning of the file? Here are
some solutions.
- Try to execute the file, i.e. type the path to the script (
./semester)
into your shell and press enter. Understand why it doesn’t work by
consulting the output ofls(hint: look at the permission bits of the
file). 
1  | ls -l semester  | 
- Run the command by explicitly starting the 
shinterpreter, and giving it
the filesemesteras the first argument, i.e.sh semester. Why does
this work, while./semesterdidn’t? 
1  | sh semester  | 
Why is that? When use sh, the system will call dash interpreter to read the file semester, where the reading is permitted. While ./semester directly execute the file which does not has execution permission.
Look up the
chmodprogram (e.g. useman chmod).Use
chmodto make it possible to run the command./semesterrather than
having to typesh semester. How does your shell know that the file is
supposed to be interpreted usingsh? See this page on the
shebang line for more
information.
1  | chmod u+x semester  | 
Use
|and>to write the “last modified” date output bysemesterinto a file calledlast-modified.txtin your home
directory.1
./semester | grep "last modified" > last-modified.txt
Write a command that reads out your laptop battery’s power level or your
desktop machine’s CPU temperature from/sys. Note: if you’re a macOS
user, your OS doesn’t have sysfs, so you can skip this exercise.
1  | # for energy  |