Navigating the File Store

Directories are files that act as pointers to file lists, it is easiest to work on a file in whose directory you are at the time as you only have to type the full path once when you switch to that directory rather than having to address the file by its full path each time.

pwd: print the working directory, for when you are feeling lost and don't know which directory you are in.

cd: Change the current working directory. Without an argument it switches to your home directory, otherwise it switches to the directory supplied as an argument. This has the side effect of setting an environment variable OLDPWD which you can change back to with cd - this allows you switch between two directories rapidly.

Where you need to work on more than two directories in a session there is a suite of tools, pushd popd & dirs -p.

  • pushd: changes to the directory supplied as an argument adds it to the directories array and displays the list of directories in the array.
  • popd: when supplied without an argument removes the last directory from the array of directories and changes to the last directory in the current array. If you specify a directory it removes that directory from the array.
  • dirs: Lists the directories in the array, when called with the -p option it prints them one per line