Due: Tue. 02/03 at 11:59PM

Overview

In this exercise, you will practice navigating and modifying files in a complex directory structure. You will repeat exercises similar to this throughout the course of the semester. Over the course of the semester, the exercises will become slightly harder. The directory structure you work with is semi-randomly generated, so each student will receive a different ones each week to work with.

Receiving your exercise

You will generate a new directory structure to work with each time you complete this exercise. There is a python script in the /home/ckazer/public directory that you can execute to create a semi-random directory structure. Navigate to where you would like to put the exercise files, and then run

$ python3 /home/ckazer/public/cs14/exercises/navigation/make_dir_structure_easy.py

Rather than copy-pasting this command, try typing it out using tab completion! Follow the prompts to generate your exercise. This will create a directory called treenav/.

Using asciinema

For this exercise, you must submit one or more asciinema recordings of you completing the exercise, as evidence of completing the assignment from the command line.

You can start an asciinema recording called naviagtion.cast as follows:

$ asciinema rec navigation.cast

Use Ctrl+d or enter the command exit to stop recording. If you record your work in multiple sessions, give each recording a different name. E.g, navigation_pt1.cast, navigation_pt2.cast, navigation_pt3.cast.

Warning
asciinema essentially functions as a "keystroke logger". You should not enter any sensitive information, like passwords or other personal data, while using it.

Completing the exercise

To begin with, there are three files you must find within treenav/:

  • re-name_me.txt

  • remove_me.txt

  • copy_me.txt

Each of the files contains instructions about what to do with the file. Use cat to read their contents and perform the necessary operations.

Reminders

  • USE TAB COMPLETION!

    • press tab after writing a command and partially completing the name of a file or directory to auto-complete the name, assuming it is unique.

    • press tab multiple times to display the possible valid completions of a command, file, or directory if there is more than one option.

  • pwd

    • If you don’t know where you are in the directory structure, use pwd to "print the working directory" of where your terminal is currently.

  • ls

    • ls with nothing after it will show the contents of the current working directory.

    • ls with the name of a directory will show the contents of that directory, e.g. if your current directory contains another directory called cs14/, then ls cs14/ will show the contents of cs14/.

  • cd

    • cd with nothing after it will return you to your home directory.

    • You can use cd to jump multiple directories at once, e.g. cd path/to/subdirectory. This works with tab completion!

    • Use cd .. to go back up a directory. This can be done multiple times at once, e.g. cd ../../../.

  • rm

    • rm file_name will attempt to delete file_name

    • Be careful! Files and directories removed with rm generally cannot be recovered.

  • mv

    • mv can be used both to move files/directories and rename files/directories.

    • mv a_file b_file changes the name of a_file to b_file

    • mv a_file sub_dir/ moves a_file into sub_dir, keeping the name a_file.

    • mv a_file sub_dir/b_file moves a_file into sub_dir AND changes its name to b_file.

  • cp

    • cp a_file b_file copies the contents of a_file into b_file.

    • cp works across directories. E.g., cp a_file ../b_file will create a copy of a_file that is one directory up called b_file.

  • tree

    • Use tree . to print the directory tree of the current directory and all of its sub-directories.

    • tree / will print the directory structure of your entire file system!

  • find

    • find is a complex command with many options and functions! It’s easiest to start with a simple set of options and learn the others as you need them.

    • To find a file whose name you know within a directory structure, you can use the following command: find <base_directory> -name <file_name> -type f. <base_directory> is the directory where you want to search, <file_name>, is the name of the file, and -type f specifies that you are looking for a file (rather than a directory).

Submitting the exercise

For the first couple weeks, you will submit your completed exercises to a GitHub Enterprise repo. You can find your repo and clone it from the CS14 Org.

Clone you repository and either perform the exercise there, or put the modified treenav directory and asciinema recording there once you are done.