How the Terminal Works

How the terminal and shell work, and what happens when you run a command.

This track explains how the terminal works: what a shell is, how commands are found and run, where their output goes, and how colors and SSH fit in. It pairs with the Bash track, which teaches the commands themselves.

  • Beginner
  • 7 lessons
  • 5 exercises
Not started yet0 of 5 exercises solved
Start lesson 1

Lessons

  1. Terminal vs Shell — Two Different ProgramsWhat people call 'the terminal' is really two programs: the terminal draws the window, and the shell runs your commands. Knowing which does what makes the rest of this track easier to follow.1 exercise
  2. What Happens When You Press EnterFollow a command from the moment you press Enter: the shell splits and expands it, finds the program using PATH, starts a process and reads its exit code.1 exercise
  3. stdin, stdout & PipesEvery program starts with three data streams: input, output and errors. Learn how redirection and pipes connect those streams to files or to other programs.2 exercises
  4. Environment Variables & Shell StartupLearn what environment variables are, how they pass from a shell to the programs it starts, and what startup files like .bashrc are for.1 exercise
  5. Colors, Cursors & Full-Screen AppsLearn how escape codes let programs color text, move the cursor and draw full-screen apps like vim, even though the terminal only receives bytes.
  6. SSH and Remote MachinesBecause a terminal session is just a stream of bytes, it works over a network connection too. Learn to use SSH to log in to and manage remote machines.
  7. Terminal CheatsheetThe mental model plus the keystrokes, on one page.

Install it on your own computer

Your computer already has a terminal. The steps below show how to open it; the examples in this track use Bash or zsh.

Bash
# Windows Terminal (get it from the Microsoft Store)
# runs three different shells:
#   PowerShell  — Windows-native (see PowerShell track)
#   cmd.exe     — the 1980s legacy shell
#   WSL bash    — a real Linux environment

wsl --install     # recommended for this track's examples

What people build with How the Terminal Works

Learn the basics first, then pick up these tools when a project needs them.

Practical uses

  • Control local and remote computers efficiently
  • Understand streams, processes, and environment variables
  • Operate full-screen text applications
  • Diagnose how developer tools communicate

Projects to try

  1. Customize a prompt
  2. Build a colored progress display
  3. Record a terminal session
  4. Write a tiny terminal emulator

Common tools and packages

Windows TerminaliTerm2AlacrittykittytmuxZellijStarshipfzf

Well-known software

VimNeovimhtopSSHLazygitGitHub CLI