What is Absolute Path? 

Absolute Path 

An absolute path is a file or directory location that describes the full route from the root of the filesystem to the target file or folder. Because it starts from the root, it is independent of the current working directory.

  • On Windows, an absolute path usually starts with a drive letter followed by a colon and backslash, like:
    • C:\Users\Alice\Documents\file.txt
  • It can also start with a network share (UNC path):
    • \\ServerName\SharedFolder\file.txt
  • On Unix/Linux/macOS, an absolute path always starts with a forward slash / which represents the root directory:
    • /home/alice/documents/file.txt

Why Use Absolute Paths?

  • Clarity: They always point to the exact same location, regardless of where your program or script is running.
  • No Ambiguity: Since it doesn’t depend on the current directory, it prevents errors related to relative locations.
  • Common in Configuration: When you need to specify a fixed resource location (like in config files, scripts, etc.)

Related Concept: Relative Path

  • A relative path is a path that is defined relative to the current directory (also called the working directory).
  • It does not begin with a drive letter or root directory.
  • Example on Windows:
    • Documents\file.txt (relative to the current directory)
  • Example on Unix:
    • docs/file.txt (relative to current folder)

Examples:

Path type Windows example Unix/Linux example
Absolute path C:\Program Files\App\app.exe /user/local/bin/app
Relative path ..\Documents\report.docx ../documents/report.docx
Network path \\Server\Shared\folder\file.txt N/A (Unix uses mounted shares)

Extra: Why Network Shares Matter

  • Network paths (UNC paths) allow you to access files on other computers or servers over a network.
  • On Windows, these start with \\ and then the server and share name.
  • On Unix, network shares are usually mounted to a directory in the filesystem and accessed via normal absolute paths.