08: Absolute and relative paths

  Wurm lab

Using cd .. allows us to change directory relative to where we are now. You can also always change to a directory based on its absolute location. E.g. if you are working in the /home/learner/learning_unix directory and you then want to change to the /tmp directory, then you could do either of the following (you should change to /home/learner/learning_unix first):

learner@:learning_unix$ cd ../../../tmp

or…

learner@:learning_unix$ cd /tmp

They both achieve the same thing, but the 2nd example requires that you know about the full path from the root level of the computer to your directory of interest (the ‘path’ is an important concept in Unix). Sometimes it is quicker to change directories using the relative path, and other times it will be quicker to use the absolute path.