Solutions

ls options

If you try to use an option (flag) that is not supported, ls and other programs will usually print an error message similar to:

jupyter-user:~$ls -j
ls: invalid option -- 'j'
Try 'ls --help' for more information.

Exploring More ls Flags

The -l flag makes ls use a long listing format, showing not only the file/directory names but also additional information such as the file size and the time of its last modification. The -h flag makes the file size "human readable", i.e. display something like 5.3K instead of 5369.

Listing Recursively and By Time

The files/directories in each directory are sorted by time of last change.

Exploring Further

We can see what is in the data folder by passing the firectory name as an argument to ls in the same way as before.

jupyter-user:~$ls -F IntroShell/data
shell-lession-data

Confirming the change

Use the pwd command we learned earlier:

jupyter-user:~$pwd
/jupyter/jupyter-user/IntroShell
`

Change directory again

We check the contents of the IntroShell folder with again with ls:

jupyter-user:~$ls
data
`

and then move into the directory with the cd command:

jupyter-user:~$cd data
jupyter-user:~$pwd
/jupyter/jupyter-user/IntroShell/data
`

And once more for luck

jupyter-user:~$ls
shell-lesson-data
jupyter-user:~$cd shell-lesson-data
jupyter-user:~$pwd
/jupyter/jupyter-user/IntroShell/data/shell-lesson-data
jupyter-user:~$ls -F
exercise-data/  north-pacific-gyre/
`

Special Directory

We can check where the special directory . refers to by changing directory to it and issuing the pwd command:

jupyter-user:$cd .
jupyter-user:$pwd
/jupyter/jupyter-user/IntroShell/data

Absolute Paths

jupyter-user:$pwd
/jupyter/jupyter-user/IntroShell/data/shell-lesson-data
jupyter-user:$cd /jupyter/jupyter-user/IntroShell

Absolute vs Relative Paths

  1. No: . stands for the current directory.
  2. No: / stands for the root directory.
  3. No: Amanda's home directory is /Users/amanda.
  4. No: this goes up two levels, i.e. ends in /Users.
  5. Yes: ~ stands for the user's home directory, in this case /Users/amanda.
  6. No: this would navigate into a directory home in the current directory if it exists.
  7. Yes: unnecessarily complicated, but correct.
  8. Yes: shortcut to go back to the user's home directory.
  9. Yes: goes up one level.

Relative Path Resolution

  1. No: there is a directory backup in /Users.
  2. No: this is the content of Users/thing/backup, but with .. we asked for one level further up.
  3. No: see previous explanation.
  4. Yes: ../backup/ refers to /Users/backup/.

ls Reading Comprehension

  1. No: pwd is not the name of a directory.
  2. Yes: ls without directory argument lists files and directories in the current directory.
  3. Yes: uses the absolute path explicitly.
  4. Correct: see explanations above.