Part One
Your File System Is a Tree
Every file on your computer lives at a specific address — its path. To understand paths, you need to understand how the file system is organised. Think of it as an upside-down tree: a single root at the top, with branches (directories) and leaves (files) growing downward.
On macOS and Linux, the root of the entire tree is written as / (a single forward slash). Everything on your computer lives inside it. Your user folder sits at /Users/yourname, and everything you create goes inside that.
Here is what a typical student workspace looks like as a tree:
├── Desktop/
├── Downloads/
│ └── budget_report.pdf
└── Files/
└── data_journalism/
├── notes.txt
├── cities.csv
└── sources/
└── contacts.txt
Reading this tree: student is a directory inside Users. Inside student there are three directories: Desktop, Downloads, and Files. Inside Files is data_journalism, which contains two files and one sub-directory called sources.
The full path to contacts.txt is /Users/student/Files/data_journalism/sources/contacts.txt. Each / in the path is a branch — a step down in the tree.
/Users/student on the Mac, /home/student on Linux. The terminal uses ~ as a shorthand for it. Whenever you open a new terminal window, you start in your home directory.
Part Two
ls — Listing What Is Around You
ls stands for list. It is one of the two commands you will use most — the other being cd. Together they let you explore the entire file system without ever touching a mouse.
On its own, ls prints the names of files and directories in your current location. Add flags for more detail:
| Command | What it shows |
|---|---|
ls | Names only — fast overview |
ls -l | Long format: permissions, owner, size in bytes, date, name |
ls -lah | Long format + all files (including hidden) + human-readable sizes (KB, MB) |
ls Downloads | List a specific directory without moving into it |
In the long format output (ls -l), the first character of each line tells you the entry type: d means directory, - means file. The number at the far left of the size column is the size in bytes (or kilobytes/megabytes with the -h flag).
$
Try: ls · ls -l · ls -lah · ls Downloads · ls Files/data_journalism
Part Three
cd — Changing Directory
cd stands for change directory. It moves you from one location to another in the file system. After running cd, your prompt will reflect the new location — and all subsequent commands will operate relative to it.
| Command | What it does |
|---|---|
cd Downloads | Go into the Downloads directory |
cd Files/data_journalism | Go two levels down in one step |
cd .. | Go up one level (to the parent directory) |
cd ../.. | Go up two levels |
cd ~ | Go directly to your home directory from anywhere |
cd | Same as cd ~ — go home |
The two dots .. are a special name that always means "the parent directory" — the directory one level up from where you are. Similarly, a single dot . means "the current directory." These two shorthands appear everywhere in terminal work.
$
Try: cd Downloads → pwd → ls → cd .. → cd Files/data_journalism → pwd → cd ~ → pwd
cd data_journalism when you are not in the parent directory will give you an error. Always check where you are with pwd before navigating. If you get lost, cd ~ always takes you home.
Part Four
Absolute and Relative Paths
Any file or directory can be addressed in two ways: by its absolute path or by a relative path. Understanding the difference is the key to never getting lost.
An absolute path starts with / and gives the full address from the root of the drive. It works the same way regardless of where you currently are. Example:
This takes you to data_journalism from anywhere in the file system — even if you are currently on the Desktop.
A relative path does not start with /. It describes a location relative to where you currently are. If you are already in /Users/student, then:
…takes you to the same destination, because the terminal looks for Files inside your current directory.
| Notation | Meaning |
|---|---|
/ | Root of the entire drive — start of every absolute path |
~ | Your home directory (/Users/student) |
. | The current directory |
.. | The parent directory (one level up) |
Part Five
Practice — Navigate a Realistic File System
The sandbox below has a more complete file system to explore. Your challenge: reach specific files using a mix of relative and absolute paths, confirm your location with pwd, and list directory contents with ls.
Suggested sequence to try:
- Start at home (
pwdto confirm). - Navigate to
Downloadsusing a relative path. Runls. - Go back home with
cd ~. - Navigate to
Files/data_journalism/sourcesin one command. - Confirm your location with
pwd. - Go up two levels with
cd ../... Where are you now? - Navigate to
/Users/student/Desktopusing an absolute path.
$
Use pwd to check location, ls to look around, cd to move
/; ls and ls -lah list what is in a directory; cd moves you between directories; .. means parent and ~ means home; absolute paths start with / and relative paths start from where you are. In Chapter 3 you will learn to create, move, copy, and delete files.
Chapter Navigation
Move between chapters.