Moving around

A path that does not start with / is relative: it starts from where you are now.

  • cd north/forest goes into north, then into forest, in one step.
  • .. is the parent directory: cd .. climbs one level.
  • . is the current directory itself.
  • cd - jumps back to the previous directory, which is handy when you bounce between two places.
cd north/forest
pwd
cd ..
cd -

Real world: shells keep the previous directory in the variable OLDPWD, and cd - reads it. Two keystrokes save typing a long path twice.