datarekha

What is the shell?

Understand what the terminal, the shell, and bash/zsh actually are — and why the command line is worth learning.

5 min read Beginner Command Line Lesson 1 of 14

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:

ShellWhere you’ll see it
bashLinux servers, older macOS, CI systems
zshmacOS default since Catalina (2019)
shMinimal POSIX shell, available everywhere
fishBeginner-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.

Terminal(the window)iTerm2, TerminalWindows TerminalShell(the program)bash, zsh, shKernel / OS(files, processes)Linux, macOSWindowsoutput
You type in the terminal; the shell reads it and asks the kernel; output flows back.

The read-eval-print loop

A shell is a loop. Every time you press Enter, the shell:

  1. Reads the line you typed
  2. Evaluates it — parses the command, sets up any pipes or redirections, then runs the program
  3. Prints the output back to the terminal
  4. 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 (ls lists files, cp copies, rm deletes)
  • options / flags — modify the behavior; usually start with - (short) or -- (long), e.g. -l or --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 username
  • macbook — 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.

Quick check

0/3
Q1You open the Terminal app on macOS. What is the *shell* in that scenario?
Q2What does the $ symbol at the end of a shell prompt indicate?
Q3A colleague sends you the command `grep -r 'TODO' ./src`. You have never used grep before. Which approach gives you practical usage examples fastest?

Sign in to track your progress

Completed lessons, your XP, level, and streak save to your account — it's free and takes a few seconds.

Related lessons

Skip to content