2.7. Additional Practice

Suppose that you are working directly inside of your home directory on Odin, execute the tree command, and observe the output below:

output from the Unix ``tree`` command showing the directory structure.
  1. If /home/users/user is the absolute path to your home directory, then which of the commands shown below would move you directly into the cs1730 directory? Select all that apply.

    1. cd /home/users/user/cs1302-unix/notes/cs1730

    2. cd ~/cs1302-unix/notes/cs1730

    3. cd cs1730

    4. cd ~/cs1730

    5. cd cs1302-unix/notes/cs1730

    6. cd /cs1302-unix/notes/cs1730

  2. Now, imagine that you have moved to the cs1730 directory, which of the following commands will get you back to your home directory?

    1. cd ~

    2. cd ../../..

    3. cd ../..

    4. cd ../

    5. cd /home/users/user

    6. cd /../../

Solutions (Don’t open until completing the questions above)
    1. Correct. This is a valid absolute path to the cs1730 directory.

    2. Correct. Using the ~ for an alias to the home directory, this will work.

    3. Incorrect. We cannot get directly into cs1730 from our home directory. This is an invalid relative path.

    4. Incorrect. cs1730 is not contained within our home directory.

    5. Correct. This is a valid relative path from our home directory to cs1730.

    6. Incorrect. This is an invalid absolute path.

    1. Correct. This command will always get you to your home directory since ~ is an alias for our home directory.

    2. Correct. This is a valid relative path that moves up three directories.

    3. Incorrect. This will move us to the cs1302-unix directory.

    4. Incorrect. This will move us up to the notes directory.

    5. Correct. This is a valid absolute path to our home directory.

    6. Incorrect. This is an invalid absolute path.