Module 00: Terminal Basics
Getting comfortable with the command line before diving into code
Learning Objectives
By the end of this module, you will:
- Understand what a terminal is and why developers use it
- Know the difference between Terminal, Shell, Bash, Zsh, PowerShell, and CMD
- Navigate the file system with confidence
- Understand what programs and binaries are
- Know how PATH works and why "command not found" happens
- Read and write commands with flags and arguments
- Feel comfortable enough to follow along with the rest of this curriculum
Time: 1-2 hours (reading + practice)
Why This Module Exists
Many programming tutorials assume you already know how to use the terminal. They'll casually say "open your terminal and run npm install" without explaining what a terminal is or how to use it.
This module fills that gap. Even if you've used computers for years, you may have avoided the command line. That's okay — we'll start from the beginning.
The terminal is not scary. It's just a different way to interact with your computer — using text instead of clicking.
What is the Terminal?
The Basic Idea
The terminal (also called the command line or console) is a text-based interface to your computer.
Instead of clicking icons and menus, you type commands. The computer reads your command, executes it, and shows you the result as text.
Why Use It?
| Task | GUI (Graphical) | Terminal |
|---|---|---|
| Create 100 folders | Click "New Folder" 100 times | mkdir folder{1..100} |
Find all .js files | Search, wait, scroll | find . -name "*.js" |
| Install a tool | Download, double-click, next, next, finish | npm install tool-name |
| Run a program | Double-click, hope it works | node app.js |
The terminal is faster, more precise, and more powerful once you're comfortable with it. And as a developer, you'll use it constantly.
Terminology: Terminal vs Shell vs Console
These terms are often used interchangeably, but they're technically different:
Terminal (or Terminal Emulator)
The window that displays text. It's the application you open.
- macOS: Terminal.app or iTerm2
- Windows: Git Bash, PowerShell, Command Prompt
- Linux: GNOME Terminal, Konsole, xterm
Shell
The program that interprets your commands. The shell runs inside the terminal.
Think of it this way:
- Terminal = the TV screen
- Shell = the TV channel
Common shells:
| Shell | Platform | Notes |
|---|---|---|
| Bash | macOS (older), Linux | The classic. Most tutorials use this. |
| Zsh | macOS (default since Catalina) | Bash-compatible with extra features. |
| PowerShell | Windows (modern) | Object-oriented, powerful but different syntax. |
| CMD | Windows (legacy) | Old Windows command prompt. Limited. |
Console
An older term, often used interchangeably with "terminal." Originally referred to physical terminals connected to mainframes.
What Should You Use?
- macOS: Use the built-in Terminal app. Your shell is likely Zsh.
- Windows: Use Git Bash (comes with Git for Windows) — commands match macOS/Linux tutorials. PowerShell works but has different syntax.
- Linux: Use your distro's terminal. Your shell is likely Bash.
Opening Your Terminal
macOS
- Press
Cmd + Spaceto open Spotlight - Type "Terminal"
- Press Enter
Or find it in: Applications → Utilities → Terminal
Windows
Git Bash (recommended) — install Git for Windows first:
- Press
Winkey - Type "Git Bash"
- Press Enter
PowerShell — pre-installed, but different syntax:
- Press
Winkey - Type "PowerShell"
- Press Enter
Command Prompt (CMD) — legacy, only if required:
- Press
Win + R - Type
cmd - Press Enter
Linux
- Press
Ctrl + Alt + T(most distros) - Or find "Terminal" in your applications menu
Your First Commands
Once your terminal is open, try these commands:
See Where You Are: pwd
pwd
Print Working Directory. Shows your current location in the file system.
Example output:
/Users/yourname
On Windows PowerShell, use:
Get-Location
# Or the alias:
pwd
See What's Here: ls
ls
List files and folders in the current directory.
Example output:
Desktop Documents Downloads Pictures
On Windows CMD, use dir instead.
Move Around: cd
cd Documents
Change Directory. Move into a folder.
cd ..
Go up one level (to the parent folder).
cd ~
Go to your home directory.
cd /
Go to the root of the file system.
Clear the Screen: clear
clear
Clears all the text from your terminal. On Windows, use cls in CMD.
Keyboard shortcut: Ctrl + L works in most terminals.
Understanding File Paths
What is a Path?
A path is the address of a file or folder. There are two types:
Absolute path: The full address from the root
/Users/yourname/Documents/projects/myapp/index.js
Relative path: The address from where you currently are
projects/myapp/index.js
Special Path Symbols
| Symbol | Meaning | Example |
|---|---|---|
/ | Root directory (macOS/Linux) | cd / |
C:\ | Root of C drive (Windows) | cd C:\ |
~ | Home directory | cd ~ |
. | Current directory | ./run.sh |
.. | Parent directory | cd .. |
Path Examples
If you're in /Users/yourname/Documents:
| Command | Result |
|---|---|
cd projects | Go to /Users/yourname/Documents/projects |
cd .. | Go to /Users/yourname |
cd ../Downloads | Go to /Users/yourname/Downloads |
cd ~/Desktop | Go to /Users/yourname/Desktop |
What is PATH?
This is one of the most important concepts for developers.
The Problem
When you type node or python or npm, how does the computer know where that program is?
You didn't type the full path like /usr/local/bin/node. You just typed node.
The Solution: PATH
PATH is an environment variable that contains a list of directories. When you type a command, the shell searches these directories (in order) to find the program.
Viewing Your PATH
macOS/Linux (Bash/Zsh):
echo $PATH
Output (example):
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Each directory is separated by : (colon).
Windows PowerShell:
$env:PATH
Directories are separated by ; (semicolon).
What This Means
When you type node:
- Shell checks
/usr/local/bin/— isnodehere? Yes! - Runs
/usr/local/bin/node
If node isn't in any PATH directory, you'll see:
command not found: node
Why This Matters
When you install programming tools (Node.js, Python, etc.), the installer usually adds them to your PATH. If something "isn't working," it often means it's not in your PATH.
What are Programs and Binaries?
When you type node or git or npm, what exactly are you running?
Programs are Just Files
Every command you run is a file stored somewhere on your computer. These files contain instructions that your computer can execute.
# Find where a program lives
which git
# Output: /usr/bin/git
# On Windows PowerShell:
Get-Command git
# Output: C:\Program Files\Git\cmd\git.exe
That file at /usr/bin/git is the Git program. When you type git, your shell finds and runs that file.
Binary vs Script
There are two main types of executable files:
Binary (compiled):
- Machine code that your CPU runs directly
- Created by compiling source code (C, C++, Rust, Go)
- Files often have no extension on macOS/Linux, or
.exeon Windows - Examples:
git,node,python(the interpreter itself) - You can't read these in a text editor — they look like gibberish
Script (interpreted):
- Human-readable text files
- Require an interpreter to run (Node.js, Python, Bash)
- Examples:
.js,.py,.shfiles - You can open and edit these in any text editor
# This is a binary — runs directly
/usr/bin/git status
# This is a script — needs Node.js to interpret it
node my-script.js
Executables
An executable is any file that can be run as a program. Both binaries and scripts can be executable.
On macOS/Linux, a file needs "execute permission" to run:
# Make a script executable
chmod +x my-script.sh
# Now you can run it
./my-script.sh
On Windows, the file extension (.exe, .bat, .ps1) determines if it's executable.
Why This Matters
Understanding that programs are files helps you:
- Debug PATH issues: "command not found" means the file isn't in your PATH
- Understand installation: Installing a program = putting a file in the right place
- Run things directly: You can always run a program by its full path
# These are equivalent (if node is in your PATH):
node app.js
/usr/local/bin/node app.js
Anatomy of a Command
Every terminal command follows a predictable structure. Once you understand it, you can read any command.
The Basic Pattern
command [options] [arguments]
- Command: The program to run (
git,npm,ls) - Options (flags): Modify how the command behaves (
-v,--help) - Arguments: What the command operates on (files, text, URLs)
Real Examples
ls -la Documents
# ↑ ↑ ↑
# │ │ └── argument: the directory to list
# │ └────── options: -l (long format) and -a (show all)
# └───────── command: list files
git commit -m "Fix login bug"
# ↑ ↑ ↑
# │ │ └── argument: the commit message
# │ └────── option: -m means "message follows"
# └───────────── command: git (with subcommand "commit")
npm install express --save-dev
# ↑ ↑ ↑
# │ │ └── option: save as dev dependency
# │ └─────────── argument: package to install
# └─────────────────── command: npm (with subcommand "install")
Options (Flags)
Options modify command behavior. There are two styles:
Short options: Single dash, single letter
ls -l # long format
ls -a # all files (including hidden)
ls -la # combine: -l and -a together
ls -l -a # same thing, written separately
Long options: Double dash, full word
npm install --save-dev
git log --oneline
ls --all # same as -a
Options with values:
git commit -m "message" # short: value follows the flag
git commit --message "message" # long: same thing
git commit --message="message" # long: with equals sign (also valid)
Common Flag Conventions
These patterns appear across many commands:
| Flag | Common Meaning |
|---|---|
-h, --help | Show help/usage information |
-v, --version | Show version number |
-v, --verbose | More detailed output |
-q, --quiet | Less output |
-f, --force | Do it without asking |
-r, --recursive | Include subdirectories |
-n, --dry-run | Show what would happen, don't do it |
-o, --output | Specify output file |
-i, --interactive | Ask before each action |
The -- Separator
Double dash by itself (--) means "everything after this is an argument, not an option":
# Problem: want to delete a file named "-rf"
rm -rf # This is an option, not a filename!
# Solution: use -- to clarify
rm -- -rf # Deletes the file literally named "-rf"
# Common with git
git checkout -- file.txt # Restore file.txt (-- clarifies it's a file, not a branch)
Getting Help
Almost every command has built-in help:
# These usually work:
command --help
command -h
# Examples:
git --help
npm --help
ls --help
# More detailed manual (on macOS/Linux):
man git
man ls
The help output follows the same pattern you just learned — now you can read it!
Usage: git commit [-a] [-m <message>] [--amend] [<file>...]
-a, --all commit all changed files
-m, --message use given message as commit message
--amend amend previous commit
Arguments
Arguments are the "things" commands operate on:
cat file.txt # one argument
cat file1.txt file2.txt # multiple arguments
cp source.txt destination.txt # two arguments with meaning (from, to)
echo "Hello, World!" # argument is text
curl https://example.com # argument is a URL
Putting It All Together
Now you can parse any command:
docker run -d -p 8080:80 --name myapp nginx:latest
# ↑ ↑ ↑ ↑ ↑
# │ │ │ │ └── argument: image to run
# │ │ │ └───────────────── option: container name
# │ │ └──────────────────────────── option: port mapping
# │ └─────────────────────────────── option: detached mode
# └──────────────────────────────────── command (with subcommand)
find . -name "*.js" -type f -exec wc -l {} \;
# ↑ ↑ ↑ ↑
# │ │ │ └── option with complex argument
# │ │ └────────── option: files only
# │ └─────────────────────── option: name pattern
# └────────────────────────── argument: where to search
Don't worry about understanding what every command does yet. The point is that you can now see the structure.
Essential Navigation Commands
Here's a quick reference of the commands you'll use constantly:
File System Navigation
| Command | Description | Example |
|---|---|---|
pwd | Print working directory | pwd |
ls | List files | ls |
ls -la | List all files (including hidden) with details | ls -la |
cd <dir> | Change directory | cd Documents |
cd .. | Go up one level | cd .. |
cd ~ | Go to home | cd ~ |
cd - | Go to previous directory | cd - |
Creating and Removing
| Command | Description | Example |
|---|---|---|
mkdir <name> | Create a directory | mkdir my-project |
touch <file> | Create an empty file | touch index.js |
rm <file> | Remove a file | rm old-file.txt |
rm -r <dir> | Remove a directory (and contents) | rm -r old-folder |
cp <src> <dest> | Copy a file | cp file.txt backup.txt |
mv <src> <dest> | Move or rename | mv old.js new.js |
Viewing Files
| Command | Description | Example |
|---|---|---|
cat <file> | Display file contents | cat package.json |
less <file> | View file (scrollable) | less README.md |
head <file> | First 10 lines | head log.txt |
tail <file> | Last 10 lines | tail log.txt |
Practical Exercises
Exercise 1: Navigate Your System
Open your terminal and complete these tasks:
- Print your current directory
- List all files (including hidden ones)
- Navigate to your home directory
- Navigate to your Desktop
- Go back to where you started (hint:
cd -)
Solution
pwd
ls -la
cd ~
cd Desktop
cd -
Exercise 2: Create a Project Structure
Create this folder structure using only the terminal:
my-first-project/
├── src/
│ └── index.js
├── tests/
└── README.md
Solution
mkdir my-first-project
cd my-first-project
mkdir src tests
touch src/index.js
touch README.md
Or in one line:
mkdir -p my-first-project/src my-first-project/tests && touch my-first-project/src/index.js my-first-project/README.md
Exercise 3: Explore Your PATH
- View your PATH:
echo $PATH(or$env:PATHon Windows) - Find where
nodeis installed:which node(orGet-Command nodeon Windows) - List what's in that directory
Solution
echo $PATH
which node
# Outputs something like: /usr/local/bin/node
ls /usr/local/bin
# Shows all programs in that directory
If node isn't found, it means Node.js isn't installed yet — we'll cover that in later modules.
Exercise 4: Parse Commands
For each command below, identify the command, options/flags, and arguments:
grep -r "TODO" ./srcmkdir -p projects/new-app/srcgit log --oneline -n 5curl -X POST -H "Content-Type: application/json" https://api.example.com
Solution
-
grep -r "TODO" ./src- Command:
grep(search for patterns) - Option:
-r(recursive, search subdirectories) - Arguments:
"TODO"(pattern to find),./src(where to search)
- Command:
-
mkdir -p projects/new-app/src- Command:
mkdir(make directory) - Option:
-p(create parent directories as needed) - Argument:
projects/new-app/src(path to create)
- Command:
-
git log --oneline -n 5- Command:
git log(git with subcommand log) - Options:
--oneline(compact format),-n 5(show only 5 commits) - Arguments: none
- Command:
-
curl -X POST -H "Content-Type: application/json" https://api.example.com- Command:
curl(transfer data from URL) - Options:
-X POST(HTTP method),-H "..."(header to include) - Argument:
https://api.example.com(URL to call)
- Command:
Windows-Specific Notes
If you're on Windows, you have choices:
Git Bash (Recommended)
Comes bundled with Git for Windows. This is what we recommend for this curriculum because:
- Commands match macOS/Linux tutorials exactly (
ls,cd,grep,cat, etc.) - No system restart or admin permissions required
- Lightweight — just install and go
- You'll need Git anyway, so you get two essential tools in one
This is what you should use to follow along with this curriculum.
PowerShell
Pre-installed on all Windows systems. Powerful, but has different syntax:
| Bash/Git Bash | PowerShell |
|---|---|
ls | ls (works!) or Get-ChildItem |
pwd | pwd (works!) or Get-Location |
cat file.txt | cat file.txt (works!) or Get-Content file.txt |
echo $PATH | $env:PATH |
which node | Get-Command node |
touch file.txt | New-Item file.txt |
PowerShell is great for Windows-specific automation, but most online tutorials use Bash syntax.
WSL (Windows Subsystem for Linux)
Runs a full Linux environment inside Windows. More heavyweight than Git Bash, but useful if you need Linux-specific tools:
- Open PowerShell as Administrator
- Run:
wsl --install - Restart your computer
- You now have Ubuntu (Linux) available!
For this curriculum, Git Bash is sufficient. Consider WSL later if you need full Linux capabilities.
Common Questions
"What if I mess something up?"
The terminal can be powerful, which means you can accidentally delete files. Some tips:
- Be careful with
rm— there's no trash can. Files are gone. - Use
rm -i— asks for confirmation before each delete. - Don't run commands you don't understand — especially those requiring elevated privileges (like
sudoon macOS/Linux or "Run as administrator" on Windows). These can modify system files and cause serious issues. For details, see Elevated Privileges (Extracurricular). - You can always
Ctrl + C— this cancels the current command.
"Why do commands look different in tutorials?"
Different shells (Bash, Zsh, PowerShell) have slightly different syntax. Most basic commands work everywhere, but you might see variations. This curriculum primarily uses Bash/Zsh syntax since it's the most common.
"Do I need to memorize all this?"
No. Bookmark this page. The goal is to be comfortable, not to memorize. With practice, the common commands become automatic. Use Ctrl + R to search your history instead of remembering exact commands.
"What's the difference between Terminal and code editors' terminals?"
Many code editors (VS Code, WebStorm) have built-in terminals. These are the same thing — a terminal running inside your editor. The advantage is you don't have to switch windows.
Going Further
Once you're comfortable with the basics, there's more to explore:
- Keyboard shortcuts: Navigate and edit commands faster with power user shortcuts
- Shell customization: Fish shell, Starship prompt, Oh My Zsh, Powerlevel10k
- Terminal multiplexing: Zellij, tmux, screen — split panes, detachable sessions
- Modern terminal emulators: iTerm2, Alacritty, Warp, WezTerm
None of this is required to continue with the curriculum. When you're ready to level up:
👉 Terminal: Going Further (Extracurricular)
For more on system-level commands, see Elevated Privileges and User Switching (Extracurricular).
Key Concepts Summary
1. Terminal = Text Interface
Instead of clicking, you type commands. Faster and more powerful once you're comfortable.
2. Shell = Command Interpreter
Bash, Zsh, PowerShell — the program that reads and executes your commands.
3. Programs are Files
Every command runs a file (binary or script) stored on your computer.
4. PATH = Where Programs Live
A list of directories your shell searches when you type a command name.
5. Commands Have Structure
command [options] [arguments] — once you see the pattern, you can read any command.
6. Navigation Commands
pwd, ls, cd — you'll use these hundreds of times a day.
Vocabulary
| Term | Definition |
|---|---|
| Terminal | A text-based interface to your computer |
| Shell | The program that interprets commands (Bash, Zsh, PowerShell) |
| Console | Another name for terminal (historical) |
| CLI | Command-Line Interface — any text-based program |
| Binary | A compiled program file containing machine code |
| Script | A text file containing code that an interpreter runs |
| Executable | Any file that can be run as a program |
| PATH | Environment variable listing directories to search for programs |
| Flag/Option | A modifier that changes how a command behaves (-v, --help) |
| Argument | Data passed to a command (files, text, URLs) |
| Working directory | The folder you're currently "in" |
| Absolute path | Full path from root (/Users/me/file.txt) |
| Relative path | Path from current location (./file.txt) |
| Home directory | Your user folder (~) |
Next Module
Module 01: What Software Is
Now that you're comfortable in the terminal, you're ready to understand what software actually is and run your first program.
Further Reading
Practice Resources
- Learn the Command Line (Codecademy) — Interactive course
- The Linux Command Line (free book) — Comprehensive reference
- ExplainShell — Paste any command to see what it does
Videos
- Fireship: The 50 Most Popular Linux & Terminal Commands — Quick overview
- Traversy Media: Command Line Crash Course — Beginner-friendly
Reflection
Before moving on, ensure you can:
- Open the terminal on your computer
- Navigate to different directories using
cd - List files in a directory using
ls - Create folders and files from the command line
- Explain what a binary vs script is
- Explain what PATH is in your own words
- Identify the command, flags, and arguments in any command
If any are unclear, practice the exercises again. Comfort with the terminal is foundational — it's worth getting right.
Ready to continue? You now have the prerequisite skills to follow along with the rest of DevFoundry. Everything from here builds on your ability to navigate and run commands in the terminal.