6.4 Path specification

Files and directories of VFS form a tree structure. The origin of every item, called the root directory, is denoted by a single slash symbol (/).

Levels of subdirectories are separated also by the slash symbol. This means that /home/thomas specifies a file or directory called thomas, and that is in a parent directory called home, and home is a subdirectory of the root directory.

Although every file or directory can be specified using this absolute path notation that starts with the root directory, most users find this notation quite redundant. As a result, each process (instance of a program in execution) has a “current working directory” (CWD). The CWD of a process is specified in the absolute notation.

Once there is a notion of a CWD, then other files and directories can be specified relative to the CWD. A relative path is one that does not start with the slash symbol. For example, the path test.txt is relative to the CWD, which means that if the CWD is /home/user1, then test.txt really specifies /home/user1/test.txt.

There are several useful notations for relative paths. A single period (.) denotes the CWD itself. This is rarely needed. A double period (..) denotes the parent folder. This means that if the CWD is /home/user1, then .. is the same as /home, and ../.. means /!

You can move up and down the directory tree in the same relative path. For example, if the CWD is /home/user1, then ../user2/test.txt specifies the absolute path of /home/user2/test.txt.