Absolute and Relative Pathnames in Linux (original) (raw)

Last Updated : 13 May, 2026

In Linux, a path is used to specify the exact location of a file or directory inside the filesystem. Since Linux follows a hierarchical directory structure starting from the root (/), paths play a crucial role in file navigation, command execution, scripting and system administration. Linux mainly uses two types of paths:

Absolute Path

An absolute path is the complete and exact location of a file or directory starting from the root directory (/). It clearly defines where a file exists in the filesystem, independent of the user’s current directory.

Example

cat /home/user/projects/linux/notes.txt

This command tells the OS to print the content written inside the file notes.txt

/home/user/projects/linux/notes.txt

This path tells Linux:

Practical Uses

**Relative Path

A relative path defines the location of a file or directory with respect to the current working directory. It does not start from the root directory.

Example

If the current directory is:

/home/user

Then the relative path:

cd projects/linux/

Moves to:

/home/user/projects/linux/

Special Symbols in Relative Paths

Linux provides special symbols to simplify relative paths:

Examples

./script.sh

cd ../../backup

Common Mistakes to Avoid

When to Use Absolute or Relative Path

Follow the instructions below to understand when to use absolute paths and relative paths

Use absolute paths when

Use relative paths when