LESSON 5 of 5//Core Navigation
Understanding paths (absolute vs relative)
Every file and directory on your Mac has an address called a path. Understanding the two types of paths — absolute and relative — is fundamental to working with the command line.
Absolute pathszsh // interactive
# Absolute paths start from the root (/)
# They always point to the same location
➜~ls /Users/developer/projects
my-app website cli-tool
# The ~ shortcut expands to your home directory
➜~echo ~
/Users/developer
Relative pathszsh // interactive
# Relative paths start from your current directory
➜~pwd
/Users/developer/projects
# These are equivalent:
➜~ls my-app/src # relative
➜~ls ./my-app/src # relative (explicit)
➜~ls /Users/developer/projects/my-app/src # absolute
When to use which?
Use relative paths when working within a project — they're shorter and portable. Use absolute paths in scripts and configuration files where the current directory might vary.
Path hierarchyzsh // interactive
# macOS filesystem structure:
/ ← root (top level)
├── Users/ ← all user accounts
│ └── developer/ ← your home (~)
│ ├── Desktop/
│ ├── Documents/
│ └── projects/
├── Applications/ ← installed apps
├── usr/ ← system utilities
└── tmp/ ← temporary files
PRACTICE//Try the commands from this lesson
INTERACTIVE_TERMINAL//sandbox
Practice terminal — try the commands from this lesson!
Type 'help' for available commands. Tab completion not available in simulator.
Try: