{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Unix Basics Quiz\n", "\n", "Only use the command line to do all these tasks. Do not use an editor unless explicitly asked for." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using the command line" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**1**. What do these key combinations do in an interactive bash session?\n", "\n", "- 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?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**2**. How do you save a file and exit \n", "\n", "- an emacs session?\n", "- a vi session?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**3**. How cna you view the last 10 commands issued?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**4**. How do you find all commands that begin with `gr`?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Working with directories" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**5**. How do you create\n", "\n", "- a new directory?\n", "- nested directories?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**6**. How do you remove\n", "\n", "- an empty directory?\n", "- a non-empty directory?\n", "- nested directories?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**7**. How do you navigate\n", "\n", "- to a new directory\n", "- back to your previous directory\n", "- to your home directory" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**8**. How do you print your current directory?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Working with files" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**9**. How do you create a new empty file?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**10** How do you create the text \"Hello world\" in a new file called `hello.txt`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**11**.. How do you append \"Goodbye cruel world\" to `hello.txt`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**12**. Edit the `hello.txt` in emacs and delete the word `cruel` then save the file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**13**. Edit `hello.txt` in vi and put the word `creul` back in its original position and save the file." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**14**. Copy the file `hello.txt` to `goodbye.txt`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**15**. Combine the contents of `hello.txt` and `goodbye.txt` to a new file `hello_goodbye.txt`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**16**. Move the files `hello.txt`, `goodbye.txt` and `hello_goodbye.txt` to a sub-directory called `text`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**17**. Delete the file `hello.txt` in `text`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**18**. Pipe lines 10-20 of `EntryQuiz.ipynb` to the `wc` command. What does the output of `wc` mean?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Compression, archival and checksums" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**19**. Use `gzip` to compress the file `hello_goodbye.txt`. Report the size of the file in bytes before and after compression." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**20**. Use `gunzip` to uncompress and recover the file `hello_goodbye.txt`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**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." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**22**. Use `tar` to combine and compress all the filesi in the `text` directory into a file `text.tar.gz`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**23**. Delete the `text` directory and all its contents recursively." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**24**. Use `tar` to recover the `text` directory from `text.tar.gz`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**25**. Check that no files have been corrupted by the `tar` forward and backward processes." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Clean up" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**26**. Delete all files and directories created in this session." ] } ], "metadata": { "kernelspec": { "display_name": "Bash", "language": "bash", "name": "bash" }, "language_info": { "codemirror_mode": "shell", "file_extension": ".sh", "mimetype": "text/x-sh", "name": "bash" } }, "nbformat": 4, "nbformat_minor": 2 }