TExcelTAD
Home › Terminal & Command Line › Terminal, Console & Shell

Terminal, Console & Shell

People use terminal, console, command line, shell and command prompt as if they meant the same thing. Most of the time that's fine, but when something goes wrong (the font looks odd, a shortcut doesn't work, a script behaves differently on another machine) it helps to know which piece is responsible. There are really three layers:

text
 ┌──────────────────────────────────────────────┐
 │  Terminal app  (Windows Terminal, Terminal,  │  draws text, fonts, colours, tabs,
 │                 iTerm2, GNOME Terminal ...)  │  turns key presses into bytes
 └───────────────────────┬──────────────────────┘
                         │  characters in / characters out
 ┌───────────────────────▼──────────────────────┐
 │  Shell  (cmd.exe, pwsh, bash, zsh)           │  reads a line, expands it,
 │                                              │  runs commands, prints results
 └───────────────────────┬──────────────────────┘
                         │  starts programs, asks for files
 ┌───────────────────────▼──────────────────────┐
 │  Operating system kernel (Windows NT, Linux, │  processes, files, memory
 │  macOS XNU) + programs (git, python, ls ...) │
 └──────────────────────────────────────────────┘

The terminal (and the console)

The terminal is the window. Its job is purely input and output: it shows characters, interprets colour codes, handles scrolling, copy and paste, fonts and tabs, and sends what you type to the program running inside it. It has no idea what cd means.

The name is historical. In the 1970s a terminal was a physical device, a keyboard and a screen (or printer) wired to a big shared computer. Today's terminal apps are terminal emulators: programs that imitate those devices so old and new command-line programs keep working.

Console is mostly a synonym. On Windows it has a specific meaning: the Windows console is the built-in system (conhost.exe) that hosts command-line programs. Windows Terminal is a newer front end for the same programs. On Linux, the console often means the text screen you get without a graphical desktop (for example after pressing Ctrl+Alt+F3).

The shell

The shell is the program that runs inside the terminal and understands commands. It:

  1. prints a prompt and waits for a line,
  2. expands it (variables like $HOME or %USERPROFILE%, wildcards like *.txt),
  3. runs built-in commands itself (cd, echo, set) or starts other programs (git, python, ping),
  4. connects inputs and outputs (redirection > and pipes |),
  5. goes back to step 1.

The four shells in this course are cmd.exe, PowerShell (pwsh.exe / pwsh), bash and zsh. Each has its own syntax: the same terminal window can run any of them, and you can start one shell from another just by typing its name.

Proof: the shell works without a terminal

A shell does not need a window at all. When a script runs from a scheduler, a build server or this site's playground, the shell's output goes to a file or a pipe instead. The tty command shows which terminal is attached to the shell; in the playground there is none:

bash · try it yourself
echo "I am running in: $BASH"
tty
echo "tty exit code: $?"
if [ -t 1 ]; then echo "output goes to a terminal"; else echo "output goes to a file or pipe"; fi
I am running in: /bin/bash
not a tty
tty exit code: 1
output goes to a file or pipe

In a real terminal on Linux, tty prints something like /dev/pts/0. Programs use this check to decide whether to print colours or progress bars: ls uses colours in a terminal and plain text when you redirect it to a file.

zsh can tell you its own name and version through built-in variables:

zsh · try it yourself
echo "Shell: $ZSH_NAME $ZSH_VERSION"
[[ -t 1 ]] && echo "terminal" || echo "no terminal"
Shell: zsh 5.9
no terminal

PowerShell keeps the same information in $PSVersionTable. Core is the cross-platform PowerShell 7; the older Windows PowerShell 5.1 reports Desktop:

powershell · try it yourself
"Edition: " + $PSVersionTable.PSEdition
"Major version: " + $PSVersionTable.PSVersion.Major
[Console]::IsOutputRedirected
Edition: Core
Major version: 7
True

The command line and the prompt

The command line is the line where you type, and by extension the whole way of working ("use the command line"). The prompt is the text the shell prints to show it's ready, such as C:\Users\ada> or ada@ubuntu:~$. Command Prompt (capital letters) is also the official name of the CMD app on Windows, which adds to the confusion.

Who does what?

Feature Terminal app Shell
Font, colours, transparency, tabs, split panes ✔
Copy and paste with the mouse ✔
The prompt text ✔
History (Up arrow) and Tab completion ✔
Variables, wildcards, redirection and pipes ✔
Scripts (.bat, .ps1, .sh) ✔
Ctrl+C to stop a program sends the signal the program receives it

A practical consequence: if Tab completion behaves differently in two windows, compare the shells; if the font or Ctrl+V differ, compare the terminal apps.

Common combinations

OS Typical terminal app Typical shell
Windows 11 Windows Terminal PowerShell, CMD, or bash inside WSL
Windows 10 Windows Console (conhost) or Windows Terminal Windows PowerShell 5.1, CMD
macOS Terminal, iTerm2 zsh
Ubuntu / Fedora GNOME Terminal / Ptyxis bash
A Linux server over SSH your local terminal app bash on the server

The last row shows the layers clearly: when you SSH to a server, the terminal is on your laptop but the shell runs on the other machine.

Learn more: Terminal Apps on Every OS · Shells Compared · OS Architecture

Test yourself

You change the font size and colour scheme. Which component did you configure?

  1. The shell
  2. The terminal app
  3. The kernel
  4. The PATH variable

Which of these is a shell, not a terminal app?

  1. Windows Terminal
  2. iTerm2
  3. zsh
  4. GNOME Terminal

What does tty print when a script's output goes to a file instead of a terminal?

  1. /dev/pts/0
  2. Nothing at all
  3. not a tty
  4. bash