What is an absolute and relative path in a Linux environment?

An absolute path always comes from the same origin.And that depends on the file system you are using. It is essential that absolute paths are always the same.

A relative path, as the term actually says, is related to an arbitrarily selected point.A relative path therefore refers to a starting point for the path, which may be at the origin of the file system, but does not have to and usually does not lie there.

So the difference is where I go to the path from.You can compare that to physical addresses. Imagine, for example, that all the people in the world would make all the address information from the Eiffel Tower. That would be an absolute path.

A relative one would be if you are looking for an alley as a supplier, are already in the village and someone asks where the delivery address is now.You’ll probably not get an answer based on the location of the Eiffel Tower. But typically you start from the place where you are and will answer more like, from here 100m down there, then right, the second left, green house on the right, approx. In the middle of the alley. This is a relative path. From where you are.

The difference is: if you started from your current location and once from the neighboring village, you would still load with the absolute path at the same house.With the relative path you would go down with 100m, first right, second left where else would land if you started in 2 different locations.

The difference between Windows and Unix-based systems here is that Windows uses drive letters that serve as a starting point for the absolute path.So the partition itself.

While Linux uses a hierarchical file system and integrates all child partitions into the main file system.Therefore, the root directory is ALWAYS used as the starting point in Linux. The root directory is also typically the origin of a partition in an average installed system. However, without drive letter.

The root directory is addressed in Linux with a simple slash “/”.This is why in Linux all absolute paths start with a slash. Relative paths do not. While in Windows absolute paths begin with the appropriate drive letter.

This is followed by information that corresponds to files and folders in the respective directory.



Absolute path.Starts from the partition. In Windows, a drive letter. In case C. The Windows folder on the partition with the drive letter C in the Windows operating system.

.. Windows

Relative path.”..” addresses the parent Ornder here. In Windows, the Windows folder is typically located on partition C. This relative path works, for example, if you are in a subfolder on hard disk C. Even if this subfolder is the Windows folder itself. Since you would also use “..” in this case to go to C: and then back to the Windows folder.

If, for example, you were in the folder “C:” users”, then this relative path specification would first switch from the “users” ornder to the parent directory.In this case, click directly on the partition C or C: and then on to the Windows folder. respectively. refer to it.

For example, this path wouldn’t work if you were directly on the Paritition D (D: ) .Because there is not only no parent folder on this partition, but usually no Windows folder, unless you create one.

The same principle applies to Linux.However, Linux does not use drive letters, but one always assumes the root directory or “/”.

For example, take the “ls” command to display folder contents.

The program is located in /usr/bin/ls

That would be the absolute path that is always the same.

A relative path would be, for example, if I was in the /home folder and specify the path from there.

Then the relative path would be from the /home folder…

.. /usr/bin/ls

So first you have to switch from /home to the parent folder / , then to the two subfolders.

For the downloads folder in the user directory, this would look like this:

absolute path: /home/<user>/Downloads

relative path (again from /home): <user>/Downloads

I would also like to say that, in fact, there is also a difference between:




First path closes with a “file name” and therefore refers to the folder itself.Second path does not close with a “file name” and therefore does not refer to the folder itself, but to the CONTENT of the Downloads folder. However, depending on how you use it, many programs will know whether to use the folder or content for the upcoming operations. In other cases, this can lead to errors.

As you can see from the example with the addresses, there are corresponding application areas for the different path information.

For example, if I want to provide files for various users in a system, I will not tell the users a relative path, but an absolute one.This means that users always know where the files are located.

A good example of the use of relative paths, on the other hand, is a website.

A website usually consists of many components such as images, text, formatting specifications, etc.networked (linked).

So we’ll create a folder for a Web page and put the file for the text and the file in it for formatting. For example, a larger, centered, and bold heading.

Let’s say this web page should be in the folder…


Let’s say the text file is called index.html (HTML = hyper TEXT markup language) and is located directly in the folder “webpage” and the file with the formatting information is called styles.css and is located in a subfolder “css”.

The text file must now know what formatting to load.So where the formatting file is located. Otherwise, we won’t get a larger, centered and bold heading.

Now we could tell the text file is the formatting file…


That would work in principle.until… attempt to move the website and continue to use it.

So move the whole folder of the website to…


so the path…


invalid because the formatting file is now in…



However, if you use the text file as a starting point for a relative path, the formatting file is still in the same relationship to the text file as before.So with a relative path, the Web page still works.

Whether the two files are in…


or in…


side by side, the relative path…


works in both cases as long as the files are in the same relationship next to each other.

Leave a Reply