UNIX Pathnames Explained: Absolute vs Relative with Clear Examples
15:12, 23.11.2026
In all Linux and Unix systems, a path is needed for the specification of the files/directories' locations in the existing filesystem. Such an approach is fundamental for the management and navigation process. In the Windows system, the same method is used, but because most users access files via the mouse, they sometimes forget about the paths behind this process.
Path can be divided into 2 major groups: relative and absolute paths. So, let’s review some aspects of the Unix paths in detail with clear examples to get a better understanding.
Understanding Absolute Paths
The absolute path is a term that is related to the description of the entire path of the file that starts from the root directory (‘/’). This path is not impacted by the current working directory, and it always starts from the root directory. Then, in the path go all the following subdirectories, and it ends with the needed file/directory.
Let’s review an example:
/home/user/document.txt
Key Features of Absolute Paths
- Determines the file location from the root directory.
- Begins with a slash (/).
- Isn’t connected with the current directory.
Example
For instance, to access a file that is called doc.txt from the root directory, use the following command:
cat /home/user/doc.txt
If you want to access the file from the current directory, you can use:
cat doc.txt
Understanding Relative Paths
Relative path is another possible variant that determines the location of the file, but in the current working directory, and it doesn’t begin with a slash. This approach is based on the navigation shortcuts to access the needed file/directory.
Key Features of Relative Paths
- Is based on the current working directory.
- Slash should not be at the beginning of the path.
- Shortcuts are used for the navigations.
Using “.” and “..” in Relative Path Names
In the relative paths, the shortcuts use the parent or current directory and determine the path depending on this. The following symbols are used in the path-names:
- Double dots (..): specifies the parent directory.
- Dot (.): specifies the current directory.
For instance, if you are in /home/kt/abc and when “..” is used as an argument to “cd” for moving a level up and going to /home/kt.
Absolute vs. Relative Path: Examples
To get a more visual understanding of both paths, let’s imagine that we are currently in 'home/kt' and you need to change the directory to 'home/kt/abc'. Now, let’s review these 2 paths through this example.
1. Changing Directories Using a Relative Path
Here is an example of this process in a relative path:
$ pwd
/home/kt # current directory
$ cd abc # move into directory "abc"
$ pwd
/home/kt/abc # new current directory
2. Changing Directories Using an Absolute Path
Here is an example using an absolute path:
pwd # /home/kt
cd /home/kt/abc # absolute path
pwd # /home/kt/abc
Final Thoughts
IT experts who are working with Unix systems should definitely understand the difference between the relative and absolute paths. With a better understanding of these processes, it will be possible to determine precise file location as well as improve filesystem navigation.