Absolute and Relative Pathnames

Absolute Pathnames

In the previous section, pathnames were introduced as the way to navigate through the file system. Remember, absolute pathnames start with the root directory. Your home directory has a shortcut for the long pathname, which is ~.

~/Tilde-slash refers to your home directory. The ~ actually replaces the /mnt/ncsudrive/u/unityid
/Slash refers to the root directory.

Relative Pathnames

UNIX/Linux systems recognize some special character combinations known as relative pathnames. These relative pathnames can be used as shortcuts to save time while accessing files and directories. For example,

../ Dot-dot-slash refers to the directory above your current working directory (the parent directory). This can be used in conjunction with other shortcuts.
./ Dot-slash refers to the current working directory. Instead of typing the long (absolute) pathname, you can use dot. This is useful when working with files in your current working directory.

You can think of an absolute pathname like a physical, named address, such as 2610 Cates Ave, Raleigh, NC 27606 (Talley Student Union). A relative path for the same location would be something like: if I’m at Withers Hall, then cross the railroad tracks and turn right to get to Talley. The absolute path would tell me where to go from any other location, but the relative path will only work if I’m at Withers.


If your current working directory is MyE115 in the tree above, what is the pathname to index.html in the www directory?

The following relative pathnames are all acceptable:

  • ../www/index.html
  • ./../www/index.html

For comparison, the absolute pathname would be: /mnt/ncsudrive/j/jshmoe/www/index.html and that could be written as ~/www/index.html as well.