Menu
Coddy logo textTech

Absolute vs Relative Paths

Part of the Fundamentals section of Coddy's Terminal journey — lesson 7 of 82.

When navigating the filesystem, you can refer to a location in two ways: using an absolute path or a relative path.

Absolute Path — starts from the root of the filesystem (/). It always points to the same location no matter where you currently are:

cd /home/documents

An absolute path always begins with /.

Relative Path — starts from your current directory. It depends on where you are right now:

cd documents

If you are currently in /home, this will take you to /home/documents.

Comparing the two:

  • If you are in /home and want to go to /home/documents:
    Absolute: cd /home/documents
    Relative: cd documents
  • If you are in /home/documents and want to go up one level:
    Absolute: cd /home
    Relative: cd ..

Special relative path symbols:

  • . — refers to your current directory
  • .. — refers to the parent directory (one level up)
cd ./documents   # same as: cd documents
cd ..            # go up one level
challenge icon

Challenge

Beginner

Navigate to the documents folder using an Relative Path, then print your current location using pwd.

Cheat sheet

There are two ways to refer to a location in the filesystem:

Absolute Path — starts from the root (/) and always points to the same location:

cd /home/documents

Relative Path — starts from your current directory:

cd documents

Special relative path symbols:

  • . — current directory
  • .. — parent directory (one level up)
cd ./documents   # same as: cd documents
cd ..            # go up one level

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals