Linux · Stage 1 – Finding Your Way Around · Lesson 12 of 51

Absolute and Relative Paths

Understand the difference between paths starting at root and paths starting from your current directory.

This command uses a complete address:

Command

cd /home/maya/Documents
Piece-by-piece explanation
  1. cd changes directory.
  2. The first slash means start at the filesystem root.
  3. home, maya, and Documents are successive branches.
  4. Replace maya with your username.
Expected output
(no output)

A successful change is silent. The destination does not depend on your starting directory.

When your current directory is /home/maya, this shorter command reaches the same place:

Command

cd Documents
Piece-by-piece explanation
  1. cd changes directory.
  2. Documents is looked up inside the current directory.
  3. There is no opening slash, so this is relative.
Expected output
(no output)

Success is silent. This works only when Documents is reachable from the current location.

The relative path . means the current directory. .. means the parent. The home shortcut ~ expands to your home path and is useful even though it does not begin with slash.