Week 1 Discussion - Unix and Command Line Basics
Week 1 Discussion - Unix and Command Line Basics#
How will the Unix shell and programming language Bash help us?
Solution to Exercise 23
using Bash we can connect many pieces of software together. For example, we can redirect the output of a program to another. The Unix shell also contains many small software tools which ease working with files.
What is Unix?#
What is Unix?
Solution to Exercise 24
Unix is an operating system which is different than the widely used Windows. The first Unix was developed in 1969 and we have nowadays many operating systems which are based on the concepts of the first Unix, e.g., tree-based file system, shell or everything is a file
Where did you see a shell (command-line interface) before?
Solution to Exercise 25
e.g., in the film Matrix or other films which feature computer hackers
at the airport when dropping off the luggage at a counter. The staff sometimes uses a command-line interface to enter passenger data
what are other words for shell?
Solution to Exercise 26
Note that in this book shell is depicted only as a command line interface. In general, shell is an interface to the operating system and it can be both graphical or text-based 1
The shell is a very direct and powerful way to manipulate a computer. … or you can wreak havoc on yourself and on others. …
Do you have an example for such a command?
Solution to Exercise 27
sudo rm -rf /
Which did/would you use to get a Unix shell?
A) Mac A) Windows WSL A) Windows + Virtualbox + Ubuntu A) cloud A) other
Command Line basics#
Which command allows to you to clear the shell?
Solution to Exercise 29
There is also a shortcut:
CTRL + L
What is the command-line prompt?
Solution to Exercise 30
Same like the literal meaning, this line prompts you to enter a command.
Which is the typical structure of commands?
A) command - options - arguments A) command - arguments - options A) arguments - command - options A) options - command - arguments A) I don’t know
Solution to Exercise 31
echo -n hello
grep -e AGCT -e AGTT reads.txt ls myfolder -l # also works
How can you reexecute the commands that you used before?
What if you are searching for a command that you used very long ago?
Solution to Exercise 32
It is also possible to search for a command using
Ctrl+Rand type a part of the command that you used before. Then press
CTRL+Ragain to jump to the next.
Alternatively you can view the history file of your shell, e.g.,
.bash_historyin bash or
Pick a command that you never seen before. If you find the command useful, prepare a one minute presentation of the command. Post your command on the chat so that everyone can present another command. You can share your screen to present the command.
You want to prepare the following directory structure on your home folder:
photos/2022 photos/2021 documents/
You start creating the directories:
But get the following error:
mkdir: cannot create directory ‘photos/2022’: No such file or directory
What could be the reason? In other words, what does the error message mean?
How could you fix this?
What is the problem with the following command sequence?
%%sh cd /tmp # use /tmp as a playground (files in /tmp are deleted after reboot) echo carrots > shopping-list.txt echo thyme > shopping-list.txt echo parsley > shopping-list.txt
How can we avoid/undo our mistake?
Did you reach the following learning objectives for this week? Discuss with your partner.
Install and/or access Bash
Execute basic commands in the command line
Create and manipluate directories
Inspect, move, copy, and delete files and folders