Foundations Module 4 · Command Line Basics

Navigating the Filesystem

Last reviewed

Beginner

What you'll learn

~15 min
  • Use pwd, ls, and cd to navigate the filesystem
  • Make a folder with mkdir and move into it
  • Understand absolute vs relative paths
  • Use path shortcuts (~, .., .) to move efficiently
  • Build a mental model of the filesystem as a tree

By the end of this lesson, you will be able to move around your computer’s filesystem entirely through the terminal — checking where you are, seeing what’s around you, and going wherever you need to go.

The mental model: a building with rooms

Think of your computer’s filesystem like a building:

  • / (root) is the ground floor — everything is inside it
  • /home is the residential floor
  • /home/user is your apartment (your home directory)
  • /home/user/projects is a room in your apartment
  • /home/user/projects/my-app is a drawer in that room

Windows uses the same shape with different labels: the ground floor is the drive (C:\), and your apartment is C:\Users\Name.

Right now, when you want to find a file, you open Finder or File Explorer and click through folders. In the terminal, you do the same thing, but by typing instead of clicking. For beginner navigation, three commands to move around plus one to make folders are enough for most tasks.

ℹHome directory paths differ by OS
  • Windows (PowerShell): C:\Users\yourname
  • macOS: /Users/yourname
  • Linux: /home/yourname
  • Windows (WSL/Git Bash): /home/yourname

This lesson’s examples use Linux-style paths. Your actual paths will match your OS, but the commands work the same way, and PowerShell accepts forward slashes too, so cd projects/my-app works there.

The four survival commands

CommandWhat it doesMemory trick
pwdShows where you arePrint Working Directory
lsShows what’s hereList
cdMoves you somewhereChange Directory
mkdirMakes a new folderMake Directory

All four work the same in PowerShell, macOS and Linux. Think of them as a map, a flashlight, your legs, and a key to a new room:

  • pwd = look at the map (where am I?)
  • ls = shine the flashlight (what’s around me?)
  • cd = walk to a new room (go somewhere)
  • mkdir = add a new room (make a folder)

Try it yourself: a 5-minute walkthrough

Use your own terminal. Start in your ai-class folder, the same one your agent uses from Lesson 1.2 (run cd ~/ai-class, or cd $HOME\ai-class in PowerShell, if you closed the window). Run each line, press Enter, and compare against the check underneath.

Step 1: Confirm where you are

Terminal window
pwd

How to check it worked: the path ends in ai-class. The prompt ends the same way: PS C:\Users\Name\ai-class> on PowerShell, name@computer ai-class % (or ~/ai-class$) on macOS and Linux.

Step 2: Make a subfolder and go into it

Terminal window
mkdir notes
cd notes
pwd

How to check it worked: mkdir prints nothing. After cd notes, your prompt ends in notes, and pwd shows a path ending in ai-class/notes (ai-class\notes on Windows). Run ls: the folder is empty, so nothing is listed.

Step 3: Step back up with ..

Terminal window
cd ..
pwd

The .. means “the folder above this one.”

How to check it worked: the prompt and pwd end in ai-class again. Run ls and you will see notes.

Step 4: Jump home with ~

Terminal window
cd ~
pwd

How to check it worked: pwd prints your home folder (C:\Users\Name, /Users/name, or /home/name). The prompt shows ~ or your user name instead of ai-class.

Step 5: Let Tab finish the name

Type cd ai-c and press the Tab key. Do not press Enter yet.

How to check it worked: the terminal completes the line to cd ai-class. If it doesn’t, press Tab twice to see the options, or type a few more letters. Now press Enter, then cd notes and pwd to confirm you’re two levels down.

Tab completion saves typing and catches typos, so use it all the time. Finish with cd ~ to head home.

💡Two lines, not &&

Some guides write mkdir my-first-project && cd my-first-project on one line. Windows PowerShell 5.1, the version built into Windows, rejects &&, while two separate lines work in every shell. This course always uses two lines.

Paths: absolute vs relative

There are two ways to describe a location, just like there are two ways to give directions:

Absolute path: the full address from the top of the filesystem (like a street address):

Terminal window
cd /home/user/projects/my-app

On Windows, the top is the drive letter instead of /:

Terminal window
cd C:\Users\Name\projects\my-app

Relative path: from where you currently are (like “turn left, then go two blocks”):

Terminal window
cd projects/my-app

If you’re already in your home folder, the relative and absolute versions take you to the same place. Relative paths are shorter, so people use them more often in daily work.

ℹHow do you know which to use?

Use relative paths when the destination is nearby (a folder inside your current location). Use absolute paths when you want to jump to a completely different area of the filesystem, or when you want to be certain about where you’re going regardless of your current location.

Special path shortcuts

SymbolMeansExample
~Your home directorycd ~ goes home
.Current directorycd . goes nowhere
..Parent directorycd .. goes up one level
/Root (top of everything) on macOS and Linux; on Windows the top is the drive, C:\cd / goes to root
../..Two levels upcd ../.. goes up two levels
💡Tab completion saves typing

Start typing a folder name and press Tab and the terminal will auto-complete it. In most Bash/Zsh terminals, press Tab twice to list all matches; in PowerShell, pressing Tab again cycles through them. This alone will save you hours of typing and prevent typos.

For example, type cd pro then press Tab, and the terminal fills in cd projects for you.

📊In Your Field: MIS / Businessclick to expand

In business analytics, you’ll often work with folder structures like /home/user/projects/q4-report/data/ with subfolders for raw data, cleaned data, and outputs. Navigating this structure with cd and ls is much faster than clicking through File Explorer, especially when you’re running scripts that process files in specific directories. Understanding paths also helps when you configure tools to read from or write to specific locations.

Putting it together: a real navigation session

Here’s what a typical session looks like. Follow the comments to understand each step:

/home/user
pwd # Where am I?
ls # What's here?
# documents projects downloads hello.txt
cd projects # Go into projects
ls # What projects do I have?
# my-app data-analysis
cd my-app # Go into my-app
ls # What files are here?
# index.html style.css README.md
cd ../.. # Go up two levels (back to /home/user)
pwd # Verify I'm home
# /home/user

Notice the pattern: navigate, look, navigate, look. You’re constantly alternating between cd (move) and ls (look around). This is how everyone uses the terminal — even experienced developers.

Practice challenge

Try this sequence in your own terminal:

  1. Start in your home folder (run cd ~ if you’re not there)
  2. Navigate into ai-class/notes in a single command
  3. Run pwd to confirm where you landed
  4. Go back to your home directory
  5. Navigate into Documents and list the files there
🧬In Your Field: Biotechclick to expand

Research data often follows a structure like /home/user/lab/experiment-2026-02/raw/ with subdirectories for each run. When you SSH into a university cluster to process data, you’ll use exactly these navigation commands to find your datasets, check output files, and move between experiment directories. The pwd command is especially critical — you always want to confirm you’re in the right experiment folder before running an analysis script.

KNOWLEDGE CHECK

You're in /home/user/projects/my-app. What command takes you to /home/user?

KNOWLEDGE CHECK

What is the difference between an absolute and relative path?

🔧

When Things Go Wrong

Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.

Symptom
I get 'No such file or directory' when I try to cd into a folder
Evidence
bash: cd: projcts: No such file or directory
What to ask the AI
"Check your spelling — 'projcts' is missing an 'e'. Run ls first to see the exact folder names, then use tab completion (type the first few letters and press Tab) to avoid typos."
Symptom
I'm lost and don't know where I am in the filesystem
Evidence
I've been using cd and now I have no idea where I am
What to ask the AI
"Run pwd to see your current location. Then run cd ~ to go back to your home directory and start fresh. There's no penalty for going home and navigating again from there."
Symptom
cd .. doesn't seem to go anywhere
Evidence
I typed cd .. but pwd still shows the same directory
What to ask the AI
"Make sure there's a space between cd and the two dots: 'cd ..' (with a space). If you're already at the root (/), cd .. won't go higher because there's nothing above root."

Key takeaways

  • Four survival commands: pwd (where am I?), ls (what’s here?), cd (go somewhere), mkdir (make a folder). They work the same in PowerShell, macOS and Linux.
  • Make a folder and enter it with two lines: mkdir name, then cd name.
  • The filesystem is a tree of nested folders. cd moves you down into folders, cd .. moves you back up.
  • Absolute paths (starting with /, or a drive like C:\ on Windows) give the full address. Relative paths give directions from where you are now.
  • ~ always means your home directory — cd ~ is your “home button.”
  • Use Tab completion to avoid typos: type the first few letters of a folder name and press Tab.
  • When in doubt: pwd to check where you are, cd ~ to go home, ls to look around.
🔍What's actually in the root (/) directory?click to expand

On macOS or Linux, if you run cd / and then ls, you’ll see folders like bin, etc, home, tmp, usr, and var. These are system directories that organize how Linux works:

  • /home — where user directories live (your stuff is here)
  • /tmp — temporary files (cleanup policy depends on system configuration)
  • /etc — system configuration files
  • /usr — system programs and libraries
  • /bin — essential command programs (like ls, cat, mkdir). Note: cd is built into the shell itself, not stored in /bin.

You’ll almost never need to go into these directly. Your work lives in /home/yourname, and that’s where you’ll spend nearly all of your time. But it’s good to know the building has other floors, even if you mostly stay in your apartment.

What’s next

You can now navigate anywhere on your computer through the terminal. In the next lesson, you’ll learn to recognise the file commands (cat, cp, mv, rm) that an AI agent runs for you, and which one deserves a second look.

Search lessons