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?
cd .cd /cd /home/amandacd ../..cd ~cd homecd ~/data/..cdcd ..
Solution
- No:
. stands for the current directory. - No:
/ stands for the root directory. - No: Amanda’s home directory is
/Users/amanda. - No: this command goes up two levels, i.e. ends in
/Users. - Yes:
~ stands for the user’s home directory, in this case /Users/amanda. - No: this command would navigate into a directory
home in the current directory
if it exists. - Yes: unnecessarily complicated, but correct.
- Yes: shortcut to go back to the user’s home directory.
- Yes: goes up one level.
Relative Path Resolution
Using the filesystem diagram below, if pwd displays /Users/thing,
what will ls -F ../backup display?
../backup: No such file or directory2012-12-01 2013-01-08 2013-01-272012-12-01/ 2013-01-08/ 2013-01-27/original/ pnas_final/ pnas_sub/

Solution
- No: there is a directory
backup in /Users. - No: this is the content of
Users/thing/backup,
but with .., we asked for one level further up. - No: see previous explanation.
- Yes:
../backup/ refers to /Users/backup/.
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/

ls pwdls -r -Fls -r -F /Users/backup
Solution
- No:
pwd is not the name of a directory. - Yes:
ls without directory argument lists files and directories
in the current directory. - Yes: uses the absolute path explicitly.