e. Exercises II

Absolute vs. Relative Paths

Starting from /Users/amanda/data, which of the following commands could Amanda use to navigate to her home directory, which is /Users/amanda?

  1. cd .
  2. cd /
  3. cd /home/amanda
  4. cd ../..
  5. cd ~
  6. cd home
  7. cd ~/data/..
  8. cd
  9. cd ..
Solution

Relative Path Resolution

Using the filesystem diagram below, if pwd displays /Users/thing, what will ls -F ../backup display?

  1. ../backup: No such file or directory
  2. 2012-12-01 2013-01-08 2013-01-27
  3. 2012-12-01/ 2013-01-08/ 2013-01-27/
  4. original/ pnas_final/ pnas_sub/

A directory tree below the Users directory where “/Users” contains thedirectories “backup” and “thing”; “/Users/backup” contains “original”,“pnas_final” and “pnas_sub”; “/Users/thing” contains “backup”; and“/Users/thing/backup” contains “2012-12-01”, “2013-01-08” and“2013-01-27”

Solution

ls Reading Comprehension

Using the filesystem diagram below, if pwd displays /Users/backup, and -r tells ls to display things in reverse order, what command(s) will result in the following output:

pnas_sub/ pnas_final/ original/

A directory tree below the Users directory where “/Users” contains thedirectories “backup” and “thing”; “/Users/backup” contains “original”,“pnas_final” and “pnas_sub”; “/Users/thing” contains “backup”; and“/Users/thing/backup” contains “2012-12-01”, “2013-01-08” and“2013-01-27”

  1. ls pwd
  2. ls -r -F
  3. ls -r -F /Users/backup
Solution