What is the shell?
Understand what the terminal, the shell, and bash/zsh actually are — and why the command line is worth learning.
What you'll learn
- The difference between a terminal, a shell, and the kernel
- How to read a shell command: command, flags, and arguments
- Where to find help when you're stuck (man, --help, tldr)
Three things people often confuse
When you “use the command line,” you are actually working with three separate things stacked on top of one another.
The terminal is just the window — the app you open. On macOS it is called Terminal (or iTerm2, Warp, etc.). On Windows it is Windows Terminal. The terminal does nothing clever; it is a box that shows text and passes your keystrokes somewhere else.
The shell is the program that lives inside that box. The shell reads what you type, figures out what you mean, and asks the operating system to do it. Common shells:
| Shell | Where you’ll see it |
|---|---|
| bash | Linux servers, older macOS, CI systems |
| zsh | macOS default since Catalina (2019) |
| sh | Minimal POSIX shell, available everywhere |
| fish | Beginner-friendly, not POSIX-compatible |
The kernel is the core of the operating system. The shell talks to it (and to other programs) on your behalf. You never interact with the kernel directly.
The read-eval-print loop
A shell is a loop. Every time you press Enter, the shell:
- Reads the line you typed
- Evaluates it — parses the command, sets up any pipes or redirections, then runs the program
- Prints the output back to the terminal
- Loops back and shows a new prompt
This is called a REPL (read-eval-print loop). Python’s interactive mode works the same way.
Anatomy of a command
A command has up to three parts, separated by spaces:
command options/flags arguments
ls -l /tmp
- command — the program to run (
lslists files,cpcopies,rmdeletes) - options / flags — modify the behavior; usually start with
-(short) or--(long), e.g.-lor--long - arguments — what the command acts on, e.g. a file path or a search term
Try it live:
ls -l /tmp
total 0
drwx------ 3 alice wheel 96 Jun 5 09:14 com.apple.launchd.xyz
-rw-r--r-- 1 alice wheel 0 Jun 5 09:00 tempfile.txt
You can stack short flags: ls -la is the same as ls -l -a (long listing plus hidden files).
The prompt
Before every line, the shell prints a prompt — a signal that it is waiting for you. A typical prompt looks like:
alice@macbook ~ $
alice— your usernamemacbook— the computer name~— your current directory (~is shorthand for your home folder)$— you are a normal user; the shell uses#instead when you are root (the administrator)
The prompt is purely informational. You do not type it — only what comes after it.
Why bother with the CLI?
The graphical interface is great for exploration. The command line is better for:
- Speed — one command replaces dozens of clicks
- Scripts — chain commands together and save them as a file you can replay
- Remote servers — SSH gives you a shell on a machine halfway around the world; there is often no graphical interface available
- Reproducibility — paste a command into a README and anyone can repeat exactly what you did
Getting help
You will forget flags. Everyone does. Three tools to know:
man ls
Opens the full manual page for ls. Press q to quit.
ls --help
Prints a shorter summary. Works for most programs.
tldr ls
Shows practical examples only. Install with brew install tldr on macOS or npm install -g tldr. Highly recommended for beginners.