Computing Foundations › The Command Line › Day 8

Day 8: Meet the Terminal: Shells, Prompts, and Commands

Day 8 of 365 — Meet the Terminal: Shells, Prompts, and Commands

After this lesson you will be able to tell the terminal, the shell, and a command apart, read any command by its anatomy, describe the read-eval-print loop your shell runs, and use history, tab completion, and the manual to work quickly at the prompt.

Course
Computing Foundations
Category
The Command Line
Reading time
≈ 40 min
Practical time
≈ 30 min
Lesson duration
1h 10m
Last verified
2026-07-12

Hands-on lab for this lesson

Lab files on GitHub: https://github.com/ai-roadmap-365/ai-roadmap-365.github.io/tree/main/labs/sections/computing-foundations/day-008-meet-the-terminal-shells-prompts-and

  1. Get the hands-on files. Clone the labs repository once (you can reuse this clone for every lesson). This works on macOS, Linux, and Windows (PowerShell or WSL):
    git clone https://github.com/ai-roadmap-365/ai-roadmap-365.github.io.git
    cd ai-roadmap-365.github.io
  2. Open this lesson's lab. Move into the directory for this specific day. Every lab lives at the same predictable path — section / subsection / week / day:
    cd labs/sections/computing-foundations/day-008-meet-the-terminal-shells-prompts-and
  3. Read the lab guide. Open `README.md` in that directory. It lists the exact commands, what each does, the expected output, and how to check your work — read it before running anything.
  4. Run it and check your work. Follow the README's "How to run" section: run the example first to see the finished result, then complete the numbered exercises in `starter/`, then run the tests. The tests pass (exit 0) only when your work is correct.
    bash tests/run_tests.sh   # or the test command named in the lab README

You can also open the lab as a local page (works offline, shows the file tree and expected output).

Learning objectives

By the end of this lesson you will be able to:

Prerequisites

Why this matters


The idea in plain language

Diagram: a command line split into command, options and arguments


Historical background


What it is — and what it is not

Diagram: the terminal emulator, the shell inside it, and the operating system beneath, with a labelled command line

It is not:


Why it was created and what problems it solves

Diagram: a graphical interface compared with a shell


How it works

The read-eval-print loop

Diagram: the shell's read, parse, execute and print cycle

Typing ls -l /Users and pressing Return does exactly five things:

  1. Prompt and read. The shell prints its prompt and waits. You type; the emulator shows the characters; nothing has run yet. Return hands over the line.

  2. Parse and expand. The shell splits the line at spaces into ls, -l and /Users, and performs any expansions — turning a * into matching filenames, for instance.

  3. Locate and launch. It searches PATH for a program named ls, asks the kernel to start it with those arguments, and waits.

  4. Print. The program writes its listing, which flows back through the shell to the emulator.

  5. Loop. The program exits and a fresh prompt appears.

Flowchart: the shell's read-eval-print loop, from typing a line to the prompt returning

Finding the program

Diagram: how the shell searches PATH to locate a command


Expansion: what happens before the program runs

Diagram: the expansions the shell performs before launching a program

An everyday analogy

Diagram: the information encoded in a shell prompt

A shop with a counter and a clerk.

The shopThe terminal
The counter and windowThe terminal emulator
The clerkThe shell
The stockroom and staffThe operating system
A written slipA command line
”Ready” on the signThe prompt
The logbook of slipsCommand history
Reference bindersman pages

Examples in practice


Implications: security, privacy, performance, scalability, and cost

Diagram: safe and unsafe habits at the command line


Alternatives: free, open source, and commercial

ToolTypeWhy you might use it
Terminal.app / GNOME TerminalBundled, freeAlready installed; entirely sufficient
iTerm2 (macOS)FreeSplit panes, better search, session history
Windows TerminalFreeThe good Windows option; use it with WSL2
Warp, GhosttyFreeModern rendering, block-based output
VS Code integrated terminalFreeThe terminal beside your editor
tmuxFree, open sourceSessions that survive disconnection

Diagram: bash compared with zsh and the other common shells

TermWhat it actually is
TerminalThe window: draws text, accepts keystrokes
Terminal emulatorThe same thing, named for the teletype it imitates
ShellThe program inside that interprets your lines
ConsoleHistorically the machine’s own attached screen
Command lineThe single line of text you typed
CLIAny program driven by typed arguments, not just the shell

When to use it — and when not to

Diagram: command history, tab completion and the manual


The AI connection


Knowledge check

quiz:
  question: "You install a tool, and running its name gives \"command not found\" — yet the file clearly exists on disk. What is the most likely explanation?"
  options:
    - "The directory containing it is not listed in PATH, so the shell never searches there"
    - "The tool was installed for a different user account"
    - "The shell needs to be restarted before any new program can be run"
    - "The file was installed without read permission for your user"
  answer_index: 0
  explanation: "The shell searches only the directories named in PATH, in order. A program outside all of them is invisible to a bare name, though it will run perfectly if you give its full path."

Hands-on exercise

Read the loop, then use it. Worked through fully in the Day 8 lab directory.

What you are doingCommand
See which shell you are inecho $SHELL
See where it searchesecho $PATH
Ask what a name really istype ls and type cd
Read a manual pageman ls (press q to quit)
Recall and edit a commandUp arrow, then Return
Complete a long nameType a few letters, press Tab

Expected output

/bin/zsh
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
ls is /bin/ls
cd is a shell builtin

Validate your work

Troubleshooting

Common mistakes


Practice assignment


Extension challenge


Quiz

Q1. Which component actually reads your typed command, interprets it, and launches the right program?

  1. The terminal emulator
  2. The keyboard driver
  3. The operating system kernel by itself
  4. The shell
Show answer

Answer: D. The shell

The terminal emulator only displays text and forwards your keystrokes; the shell is the program running inside it that parses each command line and launches the program that does the work.

Q2. In the command `ls -l /Users`, what is `-l`?

  1. An option that changes how the command behaves
  2. An argument naming the folder to act on
  3. The name of the command being run first
  4. The shell's prompt string shown before it
Show answer

Answer: A. An option that changes how the command behaves

`ls` is the command and `/Users` is the argument it acts on; `-l` is an option, or flag, that switches `ls` into its long, detailed listing format.

Q3. What does the acronym REPL stand for, describing the shell's core behaviour?

  1. Run-Execute-Process-Log
  2. Read-Eval-Print Loop
  3. Receive-Encode-Parse-Launch
  4. Render-Emit-Print-List
Show answer

Answer: B. Read-Eval-Print Loop

A shell is a read-eval-print loop: it reads a line you type, evaluates it (parsing and finding the program), prints the result, and loops back to the prompt to wait for the next command.

Q4. Why does macOS show a `%` prompt by default while many Linux systems show `$`?

  1. macOS uses a graphical shell and Linux uses a text shell
  2. The `%` means an error occurred and `$` means success
  3. macOS defaults to zsh (`%`); many Linux systems default to bash (`$`)
  4. The symbol is chosen at random each time a new terminal window is opened
Show answer

Answer: C. macOS defaults to zsh (`%`); many Linux systems default to bash (`$`)

The prompt symbol comes from the default shell: zsh, the macOS default since Catalina in 2019, traditionally uses `%`, whereas bash, a common Linux default, traditionally uses `$`.

Q5. Which statement about most commands (like `ls` or `date`) is true?

  1. They only work when connected to the internet
  2. They are features built directly into the shell program itself
  3. They are part of the terminal emulator window
  4. They are separate programs on disk that the shell launches
Show answer

Answer: D. They are separate programs on disk that the shell launches

Most commands are independent programs the shell finds by searching the PATH and then runs; the shell's job is to locate the right program and pass along your options and arguments, not to do the work itself.

Q6. What is the purpose of tab completion?

  1. It completes a partly typed command or filename
  2. It opens the manual page for a command
  3. It deletes the current line entirely
  4. It runs the previous command again
Show answer

Answer: A. It completes a partly typed command or filename

Pressing Tab asks the shell to finish a partly typed command or filename (or show the choices if several match), which saves keystrokes and prevents typos in long names.

Q7. Which command shows the reference manual for a command such as `ls`?

  1. `help ls`
  2. `man ls`
  3. `info -q ls`
  4. `ls --manual`
Show answer

Answer: B. `man ls`

`man ls` opens the manual page for `ls`; you scroll with the arrow keys and press `q` to quit. Many commands also accept `--help` for a shorter summary.

Q8. You typed `bash` to start a new shell, but `echo $SHELL` still prints `/bin/zsh`. Why?

  1. The command failed silently and no shell is running
  2. `$SHELL` is always wrong and should be ignored
  3. `$SHELL` reports your login shell, not the running one
  4. zsh and bash are the same program with two names
Show answer

Answer: C. `$SHELL` reports your login shell, not the running one

`$SHELL` names your default login shell, which stays zsh even after you start bash by hand. To see the shell running at this moment, use `echo $0` or `ps -p $$`.

Glossary

terminal
The text-based interface for typing commands to a computer and reading their text output; historically a separate device at the end of a wire, today usually a software window.
terminal emulator
The application that opens a window, displays text, and forwards your keystrokes to the shell — a program that behaves like the old physical terminal hardware it is named after.
shell
The program running inside a terminal that reads your command lines, interprets them, launches the corresponding programs, and prints their output; examples include bash, zsh, and fish.
prompt
The short piece of text a shell prints to signal it is ready for your input, such as `you@laptop %`; its exact look is set by the prompt string.
command
A single line of text you give the shell, beginning with the name of a program to run and followed by any options and arguments.
flag
An option on a command line, usually starting with `-` or `--`, that changes how a command behaves — for example `-l` in `ls -l`.
argument
The target a command acts on, such as a file or folder name — for example `/Users` in `ls -l /Users`.
bash
The Bourne Again Shell, written by Brian Fox for the Free Software Foundation in 1989; the most widely documented shell and a common default on Linux systems.
zsh
The Z shell, released by Paul Falstad in 1990; the default shell on macOS since Catalina (2019), offering richer completion and customization while staying broadly bash-compatible.
read-eval-print loop (REPL)
The repeating cycle a shell runs for every command: read the line you type, evaluate it, print the result, and loop back to the prompt to wait for the next line.
man page
A command's built-in reference manual, shown by the `man` command (for example `man ls`); you scroll with the arrow keys and press `q` to quit.
tab completion
A shell feature that finishes a partly typed command or filename when you press the Tab key, or lists the choices if several match, saving keystrokes and preventing typos.
command history
The shell's record of the commands you have run, recalled with the Up arrow or listed with the `history` command, so past commands can be re-run without retyping.
PATH
The list of directories a shell searches to find the program named by a command, so that typing `ls` locates and runs the `ls` program wherever it is installed.

Sources and further reading


Kept in this browser, no account needed. Your progress page turns the whole record into one link you can bookmark or open on another device.