What is absolute path?

The absolute path (occasionally known as the full path) of an entity contains all the informationfrom the root to the ending needed to locate that entity. Absolute paths are used to trace the location of files, folders, or webpages.

An example of directory structure
An example of directory structure

Absolute path in file systems

Different operating systems have different syntax for absolute paths.

Windows

The illustration above depicts a directory structure in a Windows environment. Below are the absolute paths to some files and folders in the sample directory:

  • Macaroni file: C:\Recipes\Pasta\Macaroni
  • Cheese cake file: C:\Recipes\Cakes\CheeseCake
  • Work folder: C:\Work
  • Audit report file: C:\Work\AuditReport

Note: Here, C:\ is the root directory.

Linux/Unix

Below is an example of an absolute path to a file stored on a Linux/Unix system:
/home/Educative/Courses/Python.txt

Note: Here, / refers to the root directory.

Mac OS

Finally, let’s look at an example of an absolute path to a file stored on a Mac OS system:
/Users/Sarah/Desktop/Educative/Courses/Java.txt

Note: Here, / refers to the root directory.

Absolute path in websites

Websites also have absolute paths. URLs hold the information to a website’s path and are usually visible on your browser’s search bar. Let’s use Educative’s website as an example. Below are the absolute paths to land on different webpages of Educative’s website:

Finally, let’s look at the absolute path to this very shot: https://www.educative.io/answers/absolute-path

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved