Linux Relative Paths

|

What is Relative Path?

Relative path means the path of a file or folder relative to your current directory. When you are in the terminal, you write the path of the file or folder from your current location.

Syntax:

cd relative_path

Example 1: Relative Path (Single Folder)

Suppose your current directory is:

/home/user/Documents

Command:

cd Projects

Explanation:

  • Here, Projects is a folder inside Documents.
  • You can use a relative path because it starts from your current directory.
  • This helps you move between folders without writing the full path.

Directory Structure Diagram:

/home
 └── user
     └── Documents
         └── Projects

Example 2: Relative Path (Multiple Folders)

If you have the Projects/Code folder inside Documents, and your current directory is Documents, then:

Command:

cd Projects/Code

Explanation:

This is also a relative path because it moves step by step through subfolders.

Directory Structure Diagram:

/home
 └── user
     └── Documents
         └── Projects
             └── Code

ONLINE WEB TOOLS

WhatIsMyIpAddress
Shorterner