Navigating in Terminal
Objectives
By the end of this chapter, you should be able to:
- Define what Terminal is and how it is structured
- Navigate through and list files on your machine
- Define the following terms: shell, terminal, directory, absolute path, relative path
๐ก Why this matters: Every developer, in every language and stack, ends up living in Terminal. It looks intimidating the first time you open it โ no icons, no menus, just a blinking cursor โ but the handful of commands in this lesson (
pwd,ls,cd) are ones you’ll type hundreds of times a day for the rest of your career. Go slowly here. By the end of this lesson, moving around your computer with just a keyboard will already start to feel natural.
What Is Terminal?
Terminal is an application that gives you a command line interface (or CLI) for interacting with your computer. Anything you can do by clicking around in Finder or File Explorer, you can also do in Terminal โ usually faster, once it clicks.
Shell vs. Terminal
You’ll hear “shell” and “terminal” used interchangeably. They’re not quite the same thing:
- The terminal is the window โ the wrapper program you’re typing into.
- The shell is the program actually reading your commands, running them, and handing back output. Bash and Zsh are the two most common shells; this course uses Zsh, the default on modern Macs.
Want the more precise definition? Here’s how Stack Overflow puts it:
The shell is the program which actually processes commands and returns output. Most shells also manage foreground and background processes, command history and command line editing… A terminal refers to a wrapper program which runs a shell.
If you’re on Windows, install Git Bash โ it gives you a Bash-like shell so you can follow along with the same commands as Mac and Linux users.
How Terminal Is Structured
Think of your filesystem like a filing cabinet. The whole cabinet is the root directory, written as /. Every drawer, folder, and file on your computer lives somewhere inside it.
/
โโโ Users
โโโ sam <- your home directory, aka ~
โโโ Desktop
โโโ Documents
โโโ Downloads
You’ll rarely touch what’s directly inside / โ that’s system-level stuff your machine needs to run. What you’ll live in day to day is your home directory: the folder for your specific user account, shown as ~. If your username is sam, your home directory is /Users/sam, and ~ is just a shortcut for that same path.
Seeing What’s Around You
Before you move anywhere, it helps to know what’s actually there. Two commands for that:
pwd(print working directory) shows the absolute path of where you are right nowls(list) shows the files and folders inside your current directory
Moving Around
The command you’ll use most in Terminal is cd โ short for change directory.
cd <folder name>moves you into that foldercd ..moves you up one levelcd ~(or justcdon its own) takes you home
That’s genuinely most of what you need to get anywhere on your machine.
Absolute Paths vs. Relative Paths
A path is the address for a file or folder. There are two ways to write one:
| Path type | Starts from | Example |
|---|---|---|
| Absolute | The root/, every time |
cd /Users/sam/Desktop |
| Relative | Wherever you currently are | cd Desktop |
Both commands above land you in the same place โ just two different routes. Absolute paths always work no matter where you start; relative paths are shorter to type but depend on your current location.
Try It
Now put it together in the sandbox below. It’s a small sandboxed file system, not a real shell, but pwd, ls, and cd behave here the same way they do everywhere.
Work through these, in order:
- Run
pwdto confirm you’re home. - Run
lsto see what’s inside. cd Desktop, thenpwdto confirm you moved.cd ..to go back up a level.- Reach
Documentstwo ways โ first withcd Documents(relative), then go home withcd ~and usecd /Users/sam/Documents(absolute).
File tree
Nice work โ that’s the same cd you’ll use for the rest of this course.
Recap
- Terminal is the window; the shell (Bash/Zsh) is what actually runs your commands.
/is the root of everything;~is your home directory.pwdtells you where you are,lsshows what’s around you,cdmoves you.- Absolute paths start from
/; relative paths start from wherever you’re standing.
You’ve got the core moves down. Next lesson, you’ll start creating, moving, and deleting real files and folders โ that’s where Terminal starts to feel genuinely useful.
Questions to Answer
- What is the difference between
/and~? What do we call each of these directories? - What command do we use to change directories?
- What is the difference between an absolute and relative path?