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 and Relative Path.
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.
- Linux does not depend on the current working directory when an absolute path is used.
- The system starts searching from the root directory (/).
- Each directory in the path is followed step by step.
- The search continues until the target file or folder is reached.
- This approach makes absolute paths reliable and unambiguous.
Characteristics of Absolute Path
- Always begins with a forward slash (/)
- Starts from the root directory
- Works from any location in the system
- Does not change based on the current directory
Example
/home/user/projects/linux/notes.txtThis path tells Linux:
- Start from /
- Go to home
- Enter User
- Move to projects/linux
- Access the file notes.txt
Practical Uses
- Used in shell scripts to avoid path confusion
- Common in cron jobs and system services
- Preferred in system configuration files
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.
- Does not begin with a slash ('/').
- Dependent on the current directory.
- Shorter and easier to type
- Changes meaning when the current directory changes

Example:
If the current directory is:
/home/userThen the relative path:
projects/linux/notes.txtPoints to:
/home/user/projects/linux/notes.txtSpecial Symbols in Relative Paths
Linux provides special symbols to simplify relative paths:
.(dot) - Refers to the current directory..(double dot) - Refers to the parent directory
Examples
./script.shRuns script.sh from the current directory.
../../backupMoves to the documents directory located one level above the current directory.
../../backup- Moves two directories up and then into
backup. - These symbols make navigation faster and reduce the need for long paths.
Example of Absolute and Relative Path
Suppose you are currently located in 'home/kt' and you want to change your directory to 'home/kt/abc'. Let's see both the absolute and relative path concepts to do this:
1. Changing directory with relative path concept:
Use relative paths to navigate directories based on your current location in the file system.
$pwd
/home/user
$cd abc
$pwd
/home/user/abc
2. Changing directory with absolute path concept:
Use an absolute path to navigate directly to a specific directory from the root, regardless of your current location.
$pwd
/home/user
$cd /home/user/abc
$pwd
/home/user/abc
Key Differences at a Glance
- Absolute paths start from /, while relative paths start from the current directory.
- Absolute paths remain the same everywhere, while relative paths change with location.
- Absolute paths are preferred for automation, whereas relative paths are preferred for quick navigation.
- Absolute paths provide clarity, while relative paths provide convenience
Common Mistakes to Avoid
- Using relative paths in scripts that run automatically
- Forgetting the current directory while using relative paths
- Mixing absolute and relative paths incorrectly
- Assuming Linux paths behave like Windows paths
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:
- Writing shell scripts
- Running background jobs
- Editing system configuration files
- Accuracy is critical
Use relative paths when:
- Navigating directories manually
- Working within a known project structure
- Performing quick file operations

