UNIX Pathnames Explained: Absolute vs Relative with Clear Examples

watch 2m, 37s
views 2

15:12, 23.11.2026

Article Content
arrow

  • Understanding Absolute Paths 
  • Key Features of Absolute Paths 
  • Example 
  • Understanding Relative Paths 
  • Key Features of Relative Paths 
  • Using “.” and “..” in Relative Path Names 
  • Absolute vs. Relative Path: Examples 
  • 1. Changing Directories Using a Relative Path 
  • 2. Changing Directories Using an Absolute Path 
  • Final Thoughts

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.

Share

Was this article helpful to you?

VPS popular offers

sale

-20%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
30 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-KVM-SSD 2048 Linux

€ 30.3 /mo

€
/mo

Billed monthly

sale

-20%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
150 GB SSD
Bandwidth
Bandwidth
Unlimited
KVM-SSD 16384 Linux

€ 49.99 /mo

€
/mo

Billed monthly

sale

-20.1%

CPU
CPU
4 Xeon Cores
RAM
RAM
2 GB
Space
Space
60 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 2048 Linux

€ 6.63 /mo

€
/mo

Billed monthly

sale

-20%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-wKVM-SSD 4096 Windows

€ 72 /mo

€
/mo

Billed monthly

-10%

CPU
CPU
6 Epyc Cores
RAM
RAM
8 GB
Space
Space
100 GB NVMe
Bandwidth
Bandwidth
Unlimited
Keitaro KVM 8192
OS
CentOS
Software
Software
Keitaro

€ 28.99 /mo

€
/mo

Billed annually

sale

-20%

CPU
CPU
8 Xeon Cores
RAM
RAM
32 GB
Space
Space
200 GB SSD
Bandwidth
Bandwidth
Unlimited
KVM-SSD 32768 Linux

€ 69.99 /mo

€
/mo

Billed monthly

sale

-20.6%

CPU
CPU
6 Xeon Cores
RAM
RAM
8GB
Space
Space
100GB SSD
Bandwidth
Bandwidth
500GB
KVM-SSD 8192 HK Linux

€ 59 /mo

€
/mo

Billed annually

sale

-20%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
100 GB SSD
Bandwidth
Bandwidth
Unlimited
KVM-SSD 8192 Linux

€ 25.85 /mo

€
/mo

Billed monthly

sale

-20%

CPU
CPU
4 Epyc Cores
RAM
RAM
4 GB
Space
Space
50 GB NVMe
Bandwidth
Bandwidth
Unlimited
wKVM-NVMe 4096 Windows

€ 18.1 /mo

€
/mo

Billed semiannually

sale

-20%

CPU
CPU
2 Xeon Cores
RAM
RAM
512 MB
Space
Space
10 GB SSD
Bandwidth
Bandwidth
300 GB
KVM-SSD 512 HK Linux

€ 7 /mo

€
/mo

Billed quarterly

Other articles on this topic

cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.