Absolute and Relative Paths

Paths may be absolute or relative.

An absolute path * is path to a file or folder starting at the root. On Unix it will begins with /, to designate the root.

An absolute path is guaranteed to get you to the location you want.

A relative path is the path to a file starting at the current location. We use the notation . (a single period) for the current working directory, and .. (two periods) for the parent of the current working directory.

Examples

Absolute paths:

/home/mst3k/file.txt 
/home/mst3k/files/file.txt
/home/mst3k/projects/project1
/home/mst3k/projects/project1/output.txt

Note that /home/mst3k/file.txt and /home/mst3k/files/file.txt are different files unless you explictly link them.

Relative paths. Suppose we are in the /home/mst3k/files folder.

./file.txt		
../files/file.txt

The relative path to file.txt in files from the project1 folder is

../../files/file.txt

Tilde Notation

In Unix the tilde ~ stands for the user’s home directory, e.g. /home/mst3k.

ls ~
ls ~/files
Previous
Next