5.2 Directory Paths
5.2.3 Types of pathnames
Pathnames specify the location of a directory or file in the directory structure. In order to navigate the directory structure, it is necessary to have an understanding of pathnames. There are two types of pathnames used with UNIX and other operating systems, absolute and relative. Either method can be used at any time. An understanding of each is critical to understanding and navigating the file system.

Absolute Pathnames
An absolute pathname specifies a file or directory in relation to the entire UNIX file hierarchy. The hierarchy begins at the / (root) directory.   If you refer to a directory using its absolute pathname, you can always be sure you will get to the correct directory since you always have the common starting point of the root directory. Absolute pathnames have the following characteristics:

  • They always start at the root (/) directory and list each directory along the path to the destination file (or directory)
  • They always use a slash (/) between each directory name in the path to indicate different directories

Relative Pathnames
A relative pathname describes the location of a file or directory as it relates to the current directory or the directory you are currently in. If you are in a directory and you want to move down the directory tree, it is not necessary to type the absolute pathname. You can just type the path starting with the name of the next directory down in the directory structure. If a pathname does not begin with a slash, it is a relative pathname.

Relative pathnames are useful because they are usually shorter than absolute pathnames. In order to use relative path names, you must know what directory you are currently in since that is your starting point. The directory you are in at any point can change so you must know where you are in the directory tree or hierarchy. Absolute pathnames are usually longer but they are consistent because you specify the path from the root every time regardless of what directory you are currently in.
Interactive Media Activity (Flash, 25 kB)
  Pathnames Exercise

Work through the media activity shown to demonstrate your understanding of absolute and relative pathnames. Refer to the Class File Tree Structure by clicking the 'tree' button located on the Menu Bar and enter the Absolute or Relative pathname for the directory or file requested. Be sure to use forward slashes and note that all directory, subdirectory and file names are case-sensitive.