The difference between absolute path & relative path in Linux

Written by stephen byron cooper Google
  • Share
  • Tweet
  • Share
  • Pin
  • Email
The difference between absolute path & relative path in Linux
Linux paths are the same as Web page addresses. (Getty Thinkstock)

Linux is an operating system that is growing in popularity for PC and notebook implementations as an alternative for Windows, or the Mac operating system. One of the main incentives to install Linux is that it is free and all updates and upgrades of the system are available for free. Another incentive is that it is managed by a not-for-profit organisation. New users need to become familiar with the terminology of Linux and how to navigate around the system. “Absolute path” and “relative path” are two of these terms.


Linux produces a Windows-like interface, called Mint. Most new users are more likely to be drawn to the Linux operating system by the ease of use of the Mint front end. Point-and-click interfaces, like Mint and Windows remove the need for the user to become experts in using the operating system. This reduces the awareness of issues such as what is a path and whether it is absolute or relative.


A path is a trail through a directory structure. The file system of Linux is organised through a series of directories with directories containing directories. This structure requires syntax to enable users and applications to access files deep inside the directory structure. Many websites are hosted on Linux machines and so most computer users are familiar with Linux paths already, without realising it. The address of a Web page contains a domain name followed by a path leading to a file name. The file contains the Web page code, the domain is the address of the site on the host computer. Everything in between is the path.


Taking a hypothetical Web address, “,” the path is the “projects/scotland/highlands” part. This explains that underneath the main directory of the site’s file structure is a directory called “projects.” There may be many files and directories in the projects directory, we do not know. However, we do know that one of the elements in that directory is the directory called “scotland.” If we looked inside the “scotland” directory, we would find another directory called “highlands.” Again, we do not know everything the “highlands” directory contains, but it is the location of at least one file, which is called “castles.htm.”

Absolute path

The request of a Web page shows a good example of an absolute path in Linux. The absolute path expresses the trail to a specific location within the directory structure. This has to be expressed as though it was commanded from outside the computer, like a request for a Web page. Within the computer, the start of the path is not a website name, but just a slash “/”, which is called the “root” directory. That castles.htm file is probably located at “/usr/asite_home/projects/scotland/highlands.” A user, exploring the file structure at the command prompt would have to issue the command “cd “/usr/asite_home/projects/scotland/highlands” to jump to that directory without having to drill through all the directories in the structure.

Relative path

A relative path can only by used from within the computer. It would not help an external user connecting into the computer. The relative path allows moves through the directory structure relevant to the current location. So, if you are in the project directory, you can switch to the highlands directory by typing “cd scotland/highlands.” You do not have to tell the “cd” command to look from the root directory all the way down through the structure to highlands. It can start from the current location. This is expressed by the absence of a slash at the beginning of the relative path.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.