Absolute and Relative Paths

Absolute and Relative Paths

by Elena Mofar, Published on May 23, 2023

Knowing the difference between Relative and Absolute Paths is very important and luckily very easy to understand.

A path is a road map which shows you how to get from one location on your Linux system directory tree to another.

It can uniquely identify a particular file or directory by using its Absolute or Relative position.

Absolute Path

An Absolute Path points to a file or directory in relation to the root directory (/).

It MUST always start with a forward slash (/) in reference to the root directory.

Whenever you log in to the system, notice that it always defaults to your home directory.

You can check the absolute path of your present directory location using the pwd command:

This is an example of an absolute path, notice that it starts with a slash (/).

Relative Path

A relative path points to a file or directory in reference to your current directory location.

As compared to an absolute path, Relative paths DOES NOT START WITH A SLASH (/) , rather, it starts with either of these 3 ways:

  1. With a period
  2. With a pair of periods (double dots)
  3. With a Sub-Directory Name or Filename

Let's evaluate them further:

With a period

  • A period represents the current working directory

With a pair of periods (double dots)

This represents the parent directory in relation to the current working directory.

Or, simply, up one directory. This is equivalent to clicking this button in Windows:

Using the double dots in Linux:

With a Sub-Directory Name or Filename

We can reference the directory or the filename by indicating it sub-directory or filename, provided that we are presently located in the directory where that file or directory exists.

Next Topic Suggestion:

Linux Command Syntax

Category Suggestion

Recent Posts

Para sa Fresh Graduates, Trabaho Ba Agad? O Aral Ulit?
Basic Python : The print( ) Function
How to Install Python 3 on your Windows Computer
Basic Linux Commands: Moving Around Directories
Linux Command Syntax