Module 1: Terminal BasicsLesson 3 of 7
0%
Lesson 3ยท4 min

Understanding File Paths

Learn how files and folders are organized on your computer

Understanding File Paths

Before we navigate around, we need to understand how your computer organizes files.

The Folder Tree

Your computer's files are organized like a tree:

plaintext
/
โ”œโ”€โ”€ Users/
โ”‚   โ””โ”€โ”€ john/
โ”‚       โ”œโ”€โ”€ Desktop/
โ”‚       โ”œโ”€โ”€ Documents/
โ”‚       โ”‚   โ””โ”€โ”€ projects/
โ”‚       โ”‚       โ””โ”€โ”€ my-app/
โ”‚       โ””โ”€โ”€ Downloads/
โ”œโ”€โ”€ Applications/
โ””โ”€โ”€ System/

Absolute vs Relative Paths

Absolute Paths

Start from the root (/) and give the complete location:

Terminal
/Users/john/Documents/projects/my-app
โ–Œ

Relative Paths

Start from where you currently are:

Terminal
# If you're in /Users/john/Documents:
projects/my-app
# If you're in /Users/john:
Documents/projects/my-app
โ–Œ

Special Path Shortcuts

SymbolMeaningExample
~Your home folder~/Documents = /Users/john/Documents
.Current folder./file.txt = file in this folder
..Parent folder../ = go up one level

Tip

The tilde ~ is incredibly useful. ~/Desktop always means YOUR desktop, regardless of your username.

Examples

Terminal
# These are the same if your username is "john":
/Users/john/Desktop
~/Desktop
# Go up one folder then into Downloads:
../Downloads
# Go up two folders:
../../
โ–Œ

Windows Note

Warning

Windows uses backslashes \ instead of forward slashes /. However, Git Bash accepts both! Windows: C:\Users\john\Documents Git Bash: /c/Users/john/Documents

Aussie Note

Think of paths like giving directions to a mate's house. Absolute: "123 Main St, Sydney NSW 2000". Relative: "Two doors down from the pub."

Key Takeaways

  • Paths are addresses for files and folders
  • Absolute paths start from root (/)
  • Relative paths start from where you are
  • ~ is shorthand for your home folder
  • .. goes up one folder