Terminal

A terminal is the device or window through which text is sent to a computer and displayed from it: historically a physical unit with a keyboard and a screen or printer connected to a distant machine, and today a program called a terminal emulator that imitates one inside a graphical desktop. Its job is narrow and mechanical, carrying keystrokes in and characters out, and it is distinct from the shell that interprets typed commands and from the command-line interface as a style of interaction.

The terminal began as hardware, and its name records that fact. In the era of time-sharing, many users reached one expensive computer from separate terminals connected by cables. First these were electromechanical teleprinters, and then video terminals such as the Lear Siegler ADM-3A of 1975 and Digital Equipment Corporation's VT100 of 1978, which showed a grid of 80 columns by 24 rows of characters and understood special control sequences to move the cursor and clear the screen. The terminal itself held no programs, which is why such units were called dumb terminals. The VT100 became so widespread that the control codes it understood, which follow the ANSI X3.64 standard now published as ECMA-48, are still imitated by every terminal emulator today.

A terminal emulator is software that recreates this old device in a window. Programs such as xterm, written for the X Window System in the 1980s, the Windows Terminal that Microsoft open-sourced in 2019, macOS Terminal, iTerm2, GNOME Terminal, Alacritty and the terminal panel in a code editor draw a grid of characters, accept keystrokes, and interpret escape sequences that set colours, move the cursor and switch the screen mode. Between the emulator and the programs it hosts sits the kernel's pseudo-terminal, or pty, a pair of connected endpoints: the emulator holds one end, and the shell's input and output are attached to the other, so that the shell believes it is talking to a real device.

Keystroke in the terminal window
for example, typing ls and Enter
Terminal emulator writes it to the pseudo-terminal
master end held by the emulator
Kernel line discipline
Echo and edit
characters echoed back, Backspace handled
Signals
Ctrl-C becomes an interrupt signal for the running program
Shell reads the line and runs the command
slave end is its standard input and output
Output returns through the pty; the emulator renders it
text plus colour and cursor escape sequences

The most common confusion is between the terminal, the shell and the console, which are three separate things. The terminal is the window or device that moves characters; the shell, such as bash, zsh, fish or PowerShell, is a program that reads a line, interprets it and starts other programs; and the console is the machine's primary built-in terminal, used for booting and emergencies. Any shell can run in any terminal, and the same terminal can host a Python interpreter, a text editor or a database client instead of a shell. Changing the terminal changes fonts, colours, tabs and speed; changing the shell changes how commands are parsed, which is why a script that works in bash may fail in another shell.

The line discipline in the kernel is why some familiar keystrokes work the way they do. In the default mode, the kernel buffers a line and lets the user edit it before sending it on, and it translates Ctrl-C to an interrupt signal for the foreground program, Ctrl-D to an end-of-input marker and Ctrl-Z to a suspend. Programs that need every keystroke immediately, such as vim, htop or a terminal-based dashboard, switch the terminal to raw mode and draw the screen themselves with escape sequences. This also explains why tools behave differently when their output is redirected to a file: many check whether they are attached to a terminal before adding colour or progress bars.

Terminals matter in current practice because remote and automated work happens through them. SSH carries a terminal session across the network to a server, and multiplexers such as GNU screen and tmux (first released in 2007) keep sessions alive after disconnection, which is essential for long training jobs on remote GPU machines. Notebook environments, container shells and cloud consoles all embed terminals. A practical hazard is that pasting text into a terminal can execute it, so commands copied from a website can run hidden instructions, and escape sequences in untrusted output have occasionally been abused to manipulate what a terminal displays.

Read a terminal as the conduit and not the conversation: it carries keystrokes in and characters out, descended from a physical screen and keyboard on a cable, while the shell it hosts interprets the commands and the command-line interface is the habit of working that way.

Take terminal further

Ask the copilot about this term, or have our engineers assess it against your process.