This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 2: Commands

Quiz

face Harry Coppock

Let us have a quick quiz to check whether you actually remembered and understood what you have learnt!

This quiz is ungraded, so feel free to make as many mistakes as you like - that is how you learn!

1 2 3 4

Question 1

Take the following directory structure:

.
├── A
│   └── end.txt
├── B
└── C
    ├── D
    └── E
        └── F
            └── start.txt
on running pwd the output is /Users/hgc/teaching/python/cd_test/C/E/F. Using relative paths change to the directory containing end.txt with one command.

cd ../../../A
Explanation:

We asked to use the relative path.

Question 2

For the python file data_visulisation.py, does hgc19 have permission to run python data_visulisation.py? The output for ls -l is:

-rw-r--r-- 1 hgc19 ibug 2459 Aug 27 17:09 data_visualisation.py
hint: you might want to check out this stackoverflow thread: link

you sure can!
Explanation:

Don't worry too much if you are confused by this - but the command here is python and it only needs to read the file. It is the python application which needs execute rights.

Question 3

Take the following directory structure:

.
├── A
│   └── end.txt
├── B
└── C
    ├── D
    └── E
        └── F
            └── start.txt
on running pwd the output is /Users/hgc/teaching/python/cd_test/C/E/F. Using relative paths move the file start.txt to /Users/hgc/teaching/python/cd_test/B and change it's name to start_1.txt ```

mv start.txt ../../../B/start_1.txt

Question 4

Take the following directory structure:

.
├── A
│   └── end.txt
├── B
│   ├── start_1.txt
│   └── start_2.txt
└── C
    ├── D
    │   └── start_3.txt
    └── E
        └── F
the current working directory is /Users/hgc/teaching/python/cd_test/C/. Using relative paths, delete B and all it's contents. You do not want any warning messages raised.

rm -rf ../B