These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Understanding Paths And Pathnames

Classnotes | UNIX01 | RecentChanges | Preferences

As we have already seen, the forward slash (/) is the separator under UNIX for directories. We have also seen that "." refers to the current directory and ".." refers to the parent directory. UNIX is intelligent enough to allow mixing and matching of absolute and relative paths.

Absolute Paths

An absolute path is one which names the full path of an object explicitly. For example, if I had a home directory under /home, my user name was "steve", and I had a subdirectory called "files" which contained the file "padlock.dat", the full absolute path of that file would be:
 /home/steve/files/padlock.dat

I could specify this absolute path when refering to that file in any application or system utility.

Relative Paths

A relative path is one which names the path to an object from your current location. As a simple example, if I wanted to read "grecian.txt" which was located one directory up from my current location, I could issue
 $ less ../grecian.txt

I could likewise access a file in a subdirectory underneath my current directory

 $ less some/subdirectory/tree/file.txt

A more complicated example could be the following

 $ less ../../path/to/another/place/file.txt

Combining Relative and Absolute Paths

While its uses may not be immediately apparent, you can combine both relative and absolute paths in a single command line. For example
 $ cat /home/bob/../bob-backup/file.txt


Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited July 12, 2003 7:20 am (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.