Getting Down with the Unix CLI Lesson 2 Exercise 5

Type each of the following commands at the unix command prompt. Observe the result of each, and apply your new understanding of the file system to make sense of what you see.

  1.   $ mkdir newdir 
      
  2.   $ mkdir newdir/subdir1
      
  3.   $ mkdir newdir/subdir1/subsubdir1
      
  4.   $ cd newdir
      
  5. As in the previous exercise, try to anticipate what you will see before running this command. If you can't, reread the lesson and see if that can help you figure out what is going on.

      $ ls

    You should see only the subdir1 directory.

  6.   $ mkdir subdir1/subsubdir2 
      
  7.   $ mkdir subdir1/subsubdir3 
      
  8.   $ mkdir subdir1/subsubdir4 
      
  9.   $ mkdir subdir2 
      
  10.   $ mkdir subdir2/subsubdir1 subdir2/subsubdir2 subdir2/subsubdir3

    The mkdir command can take more than one argument, seperated by a space. Each argument is a new directory to create. Running this command will create three new directories.

  11.   $ touch subdir2/subsubdir2/file1.txt 
      
  12.   $ mkdir subdir2/subsubdir3/subsubsubdir1
      
  13.   $ touch subdir2/subsubdir3/subsubsubdir1/file2.txt 
      
  14.   $ tree ../newdir

    If you followed each step correctly, you will see this in your terminal:

    newdir tree

    Note the argument to the tree command, ../newdir. Since the tree command was run from within the directory, newdir, we needed to first move to the parent of newdir, .., from where newdir can be seen by tree.

  15. To test your understanding, answer the following questions before you run the command. If you can answer them correctly, you can have confidence that you understand what we have learned so far.
    1. What would you see if you ran $ ls from inside the newdir directory?
    2. What would you see if you ran $ ls from inside the subdir1 directory?
    3. What would you see if you ran $ ls from inside the subdir2 directory?
    4. What would you see if you ran $ tree subdir2/subsubdir3 from inside the newdir directory?