Path Name in File Directory (original) (raw)

Last Updated : 25 Apr, 2026

When files are organized as a directory tree, there must be a way to uniquely identify and access them. This is done through path names. A path name specifies the location of a file or directory in the file system hierarchy. There are two main types of path names:

1. Absolute Path Name

An absolute path name (also known as a full path) specifies the complete path from the root directory ("/") to the target file or directory. It does not depend on the current working directory, which makes it unique and unambiguous.

Example:

UNIX/Linux: /var/mail/username

Windows: C:\Users\Username\AppData\Local\Microsoft\Outlook\

Here,

When to Use:

Absolute path names are used when:

Example in UNIX:

cp /usr/ast/mailbox /usr/ast/mailbox.bak

This command copies the file mailbox from /usr/ast/ to a backup file in the same directory, using absolute paths.

2. Relative Path Name

A relative path name specifies the file or directory in relation to the current working directory (also known as the present working directory). It does not start from the root and is shorter and more flexible than an absolute path.

Example:

If the current working directory is:

/usr/ast

Then the absolute path /usr/ast/mailbox can be referred to simply as:

mailbox

Example in UNIX:

cp mailbox mailbox.bak

This command performs the same operation as the earlier absolute path example, assuming the working directory is /usr/ast.

When to Use:

Relative path names are used when:

Working Directory Concept

The working directory (or current directory) is the directory that the operating system considers as the default for all relative path operations.

You can: View it using:

pwd

Change it using:

cd /usr/ast

Once the working directory is set, all file operations using relative paths are performed relative to this directory.

Absolute vs Relative Path

Criteria Absolute Path Relative Path
Definition Full path from root directory Path relative to current working directory
Dependency Independent of working directory Depends on working directory
Uniqueness Always unique May vary depending on current directory
Usage Used in scripts or programs requiring fixed file references Used in user-level commands or local navigation
Example (UNIX) /usr/lib/dictionary ../lib/dictionary

Use of Absolute Path Names

Absolute paths are preferred when:

**Example: A spell-checking program may need to read the dictionary file at:

/usr/lib/dictionary

Since the working directory during execution may vary, using an absolute path ensures it always finds the file correctly.