Unix Basics Quiz¶
Only use the command line to do all these tasks. Do not use an editor unless explicitly asked for.
Using the command line¶
1. What do these key combinations do in an interactive bash session?
- CTRL-b, CTRL-f, CTRL-d, CTRL-t, ESC-b, ESC-f, ESC-d, CTRL-a, CTRL-e, CTRL-k, CTRL-y, CTRL-r, CTRL-n, CTRL-p?
2. How do you save a file and exit
- an emacs session?
- a vi session?
3. How cna you view the last 10 commands issued?
4. How do you find all commands that begin with gr
?
Working with directories¶
5. How do you create
- a new directory?
- nested directories?
6. How do you remove
- an empty directory?
- a non-empty directory?
- nested directories?
7. How do you navigate
- to a new directory
- back to your previous directory
- to your home directory
8. How do you print your current directory?
Working with files¶
9. How do you create a new empty file?
10 How do you create the text “Hello world” in a new file called
hello.txt
.
11.. How do you append “Goodbye cruel world” to hello.txt
.
12. Edit the hello.txt
in emacs and delete the word cruel
then save the file.
13. Edit hello.txt
in vi and put the word creul
back in its
original position and save the file.
14. Copy the file hello.txt
to goodbye.txt
.
15. Combine the contents of hello.txt
and goodbye.txt
to a
new file hello_goodbye.txt
.
16. Move the files hello.txt
, goodbye.txt
and
hello_goodbye.txt
to a sub-directory called text
.
17. Delete the file hello.txt
in text
.
18. Pipe lines 10-20 of EntryQuiz.ipynb
to the wc
command.
What does the output of wc
mean?
Compression, archival and checksums¶
19. Use gzip
to compress the file hello_goodbye.txt
. Report
the size of the file in bytes before and after compression.
20. Use gunzip
to uncompress and recover the file
hello_goodbye.txt
.
21. Create a file called MD5SUM of the MD5 checksums of the three
text files in the directory. Keep MD5SUM in the parent directory of
text
- i.e. in the current directory.
22. Use tar
to combine and compress all the filesi in the
text
directory into a file text.tar.gz
.
23. Delete the text
directory and all its contents recursively.
24. Use tar
to recover the text
directory from
text.tar.gz
.
25. Check that no files have been corrupted by the tar
forward
and backward processes.
Clean up¶
26. Delete all files and directories created in this session.