3.3 Relative pathnames

If you give a filename with no slashes or directory names before it at all, then Unix assumes that you mean the file of that name in the current directory. This is an example of a relative pathname. A relative pathname is any pathname which doesn't begin with a slash (/) or tilde (~) character. It identifies the location of a file relative to the current directory. For example, suppose (as in the example of section 3.1) that the current directory were /home/ugrad/myname, your home directory. Then the pathname Stuff.doc refers to the top file of that name, and not the file of the same name in the directory Dir2. That file would be referred to as Dir2/Stuff.doc.

Unix provides some convenient shorthand for constructing relative pathnames, namely:

'.' Always stands for the current directory.
'..' Always stands for the parent of the current directory.

So in the simple example above, if your current directory were Dir2, then the quickest way to reference Picture.gif, which lies in the parent directory, would be to type ../Picture.gif.


Keith Orpen, who is still writing this, would like to hear your comments and suggestions.