Week 1 Discussion - Unix and Command Line Basics#

Introduction#

Exercise 23

How will the Unix shell and programming language Bash help us?

What is Unix?#

Exercise 24

What is Unix?

Exercise 25

Where did you see a shell (command-line interface) before?

Exercise 26

what are other words for shell?

Exercise 27

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?

Getting Unix#

Exercise 28

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#

Exercise 29

Which command allows to you to clear the shell?

Exercise 30

What is the command-line prompt?

Exercise 31

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

Exercise 32

  • How can you reexecute the commands that you used before?

  • What if you are searching for a command that you used very long ago?

Exercise 33

Browse

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.

Exercise 34

You want to prepare the following directory structure on your home folder:

photos/2022
photos/2021
documents/

You start creating the directories:

mkdir photos/2022

But get the following error:

mkdir: cannot create directory ‘photos/2022’: No such file or directory
  1. What could be the reason? In other words, what does the error message mean?

  2. How could you fix this?

Solution to

  1. It means that a file or directory does not exist, so the command fails. In this case the missing thing is the directory photos. mkdir cannot create 2022, because the parent directory photos does not exist.

  2. We could first mkdir photos, then mkdir photos/2022. There is an easier way though. From man mkdir:

    -p, --parents no error if existing, make parent directories as needed …

    So using -p creates all the parent directories if required.

Exercise 35

  1. 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
    
  2. How can we avoid/undo our mistake?

Final reflection#

Exercise 36

Did you reach the following learning objectives for this week? Discuss with your partner.

  • Describe Unix

  • Install and/or access Bash

  • Execute basic commands in the command line

  • Create and manipluate directories

  • Inspect, move, copy, and delete files and folders