Breakout exercises for Lecture 3
Getting Started
- Turn on your camera (if possible)
- Turn on your mic (if possible)
- Introduce yourself. hint: go in aphabetical order by name
- Determine if one person is willing to screen share
- Find a terminal and log into Klaatu
if there are connectivity problems have only one person do this. They can screen-share and the group can go through the commands together.
Can't get on Klaatu?
- Check spam if you didn't get your email
If you are still having trouble, record your breakout-room-number, leave your breakout room and come talk to Professor Hazen in the main Zoom room; we'll sort it out.
HW0
- Record a script -
script testing.script
- Try the commands -
whoami, pwd, uname -a
- Did your script work? -
exit
vi testing.scriptRemember how to exit Vi?
- What does uname tell you? -
man uname
- Do you have gcc installed? -
gcc --version -std=c11
- Learn more about what shell you have -
echo $SHELL
Is it Bash?
- What is Bash? -
man bash
You should be able to do HW0 in just a couple of minutes at this point. Complete it as written, and then submit your resulting HW0.script file to Canvas. Please note - each student should submit their own version of HW0. Do not use one you worked on in this breakout room.
Things to Try
The goal of this part of today's session is to explore. You don't have to turn this in, but try the commands. Keep a record: script explore.script
- what is globbing? - try, in order,
ls, ls *.script
- Explainer - globbing translates the input
*.script, finding all potential matches, and then applies the command ls to each one.
- what is echo? -
man echo
- try more -
echo "374 rocks!"
Hmmm... what about echo '374 rocks!'
- Explainer - in Bash double quotes and single quotes behave differently. Double quotes allow elements of the string to be evaluated before printing - in this case the exclamation point.
- The error message for the double quotes said something about !" command
! - What happened there?
!l - Now what?
- Explainer -
! is a special command in Bash that allows you to use a previous command. Following it by a letter searches for the last command that started with that letter. If you use history, you can also use !num to repeat a certain previous command.
- Try the following commands:
echo $SHELL, echo "$SHELL", echo SHELL
- Explainer - SHELL is a variable in Bash. The $ before it says 'evaluate this variable' so we see the value of the variable. If we just name the variable, the interpreter treats it like any other string.
- Want to find more variables? Try
printenv or set | less
These commands both list variables set in the current environment. Can you figure out what any of them do? Where do you think you could learn more about a certain variable?
- Try setting a variable -
PS1="$LOGNAME says to: "
What happened? Can you break down the command?
Note: Learn how to make this change to persist every time you open a shell next week!