Skip to main content

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?

TaskGUI (Graphical)Terminal
Create 100 foldersClick "New Folder" 100 timesmkdir folder{1..100}
Find all .js filesSearch, wait, scrollfind . -name "*.js"
Install a toolDownload, double-click, next, next, finishnpm install tool-name
Run a programDouble-click, hope it worksnode 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:

ShellPlatformNotes
BashmacOS (older), LinuxThe classic. Most tutorials use this.
ZshmacOS (default since Catalina)Bash-compatible with extra features.
PowerShellWindows (modern)Object-oriented, powerful but different syntax.
CMDWindows (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

  1. Press Cmd + Space to open Spotlight
  2. Type "Terminal"
  3. Press Enter

Or find it in: Applications → Utilities → Terminal

Windows

Git Bash (recommended) — install Git for Windows first:

  1. Press Win key
  2. Type "Git Bash"
  3. Press Enter

PowerShell — pre-installed, but different syntax:

  1. Press Win key
  2. Type "PowerShell"
  3. Press Enter

Command Prompt (CMD) — legacy, only if required:

  1. Press Win + R
  2. Type cmd
  3. 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

SymbolMeaningExample
/Root directory (macOS/Linux)cd /
C:\Root of C drive (Windows)cd C:\
~Home directorycd ~
.Current directory./run.sh
..Parent directorycd ..

Path Examples

If you're in /Users/yourname/Documents:

CommandResult
cd projectsGo to /Users/yourname/Documents/projects
cd ..Go to /Users/yourname
cd ../DownloadsGo to /Users/yourname/Downloads
cd ~/DesktopGo 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:

  1. Shell checks /usr/local/bin/ — is node here? Yes!
  2. 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 .exe on 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, .sh files
  • 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:

FlagCommon Meaning
-h, --helpShow help/usage information
-v, --versionShow version number
-v, --verboseMore detailed output
-q, --quietLess output
-f, --forceDo it without asking
-r, --recursiveInclude subdirectories
-n, --dry-runShow what would happen, don't do it
-o, --outputSpecify output file
-i, --interactiveAsk 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

CommandDescriptionExample
pwdPrint working directorypwd
lsList filesls
ls -laList all files (including hidden) with detailsls -la
cd <dir>Change directorycd Documents
cd ..Go up one levelcd ..
cd ~Go to homecd ~
cd -Go to previous directorycd -

Creating and Removing

CommandDescriptionExample
mkdir <name>Create a directorymkdir my-project
touch <file>Create an empty filetouch index.js
rm <file>Remove a filerm old-file.txt
rm -r <dir>Remove a directory (and contents)rm -r old-folder
cp <src> <dest>Copy a filecp file.txt backup.txt
mv <src> <dest>Move or renamemv old.js new.js

Viewing Files

CommandDescriptionExample
cat <file>Display file contentscat package.json
less <file>View file (scrollable)less README.md
head <file>First 10 lineshead log.txt
tail <file>Last 10 linestail log.txt

Practical Exercises

Exercise 1: Navigate Your System

Open your terminal and complete these tasks:

  1. Print your current directory
  2. List all files (including hidden ones)
  3. Navigate to your home directory
  4. Navigate to your Desktop
  5. 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

  1. View your PATH: echo $PATH (or $env:PATH on Windows)
  2. Find where node is installed: which node (or Get-Command node on Windows)
  3. 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:

  1. grep -r "TODO" ./src
  2. mkdir -p projects/new-app/src
  3. git log --oneline -n 5
  4. curl -X POST -H "Content-Type: application/json" https://api.example.com
Solution
  1. grep -r "TODO" ./src

    • Command: grep (search for patterns)
    • Option: -r (recursive, search subdirectories)
    • Arguments: "TODO" (pattern to find), ./src (where to search)
  2. 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)
  3. git log --oneline -n 5

    • Command: git log (git with subcommand log)
    • Options: --oneline (compact format), -n 5 (show only 5 commits)
    • Arguments: none
  4. 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)

Windows-Specific Notes

If you're on Windows, you have choices:

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 BashPowerShell
lsls (works!) or Get-ChildItem
pwdpwd (works!) or Get-Location
cat file.txtcat file.txt (works!) or Get-Content file.txt
echo $PATH$env:PATH
which nodeGet-Command node
touch file.txtNew-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:

  1. Open PowerShell as Administrator
  2. Run: wsl --install
  3. Restart your computer
  4. 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 sudo on 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:

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

TermDefinition
TerminalA text-based interface to your computer
ShellThe program that interprets commands (Bash, Zsh, PowerShell)
ConsoleAnother name for terminal (historical)
CLICommand-Line Interface — any text-based program
BinaryA compiled program file containing machine code
ScriptA text file containing code that an interpreter runs
ExecutableAny file that can be run as a program
PATHEnvironment variable listing directories to search for programs
Flag/OptionA modifier that changes how a command behaves (-v, --help)
ArgumentData passed to a command (files, text, URLs)
Working directoryThe folder you're currently "in"
Absolute pathFull path from root (/Users/me/file.txt)
Relative pathPath from current location (./file.txt)
Home directoryYour 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.

👉 Module 01: What Software Is


Further Reading

Practice Resources

Videos


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.