Definition
A shell is a program that reads commands from the user, expands them according to a defined syntax, and dispatches them to the operating system as process executions. It is both an interactive command interpreter — the prompt at which a user types — and a programming language — the syntax in which scripts are written. The Unix shell is unusual among programming languages in being designed primarily to compose other programs rather than to compute in itself; its native types are strings, its native operations are process creation and inter-process I/O routing, and its native control structures (if, while, case) are organized around the exit status of child processes.
Common shells include sh (the POSIX standard, the lowest common denominator), bash (the Bourne-again shell, the GNU/Linux default), zsh (extended, with rich interactive features, the macOS default), fish (modern, opinionated, non-POSIX), dash (a minimal POSIX shell, often /bin/sh on Debian-derived systems), and PowerShell (Microsoft's object-oriented shell, also available on Linux and macOS).
Why it matters
How it works
The shell's central loop is straightforward. It reads a line, performs a long list of expansions on it — alias substitution, brace expansion, tilde expansion, parameter expansion, command substitution, arithmetic expansion, word-splitting, pathname expansion (globbing), and finally quote removal — and then executes the resulting command. Built-in commands (cd, export, read, pwd) are handled by the shell itself; external commands are run by fork() plus exec(), with the shell waiting for the child to exit and capturing its status. Pipelines connect multiple children through kernel pipes; redirections rewire their file descriptors before exec; control structures branch on exit codes.
A shell script is the same machinery driven from a file rather than the keyboard. The first line, the shebang (#!/bin/bash or #!/usr/bin/env bash), tells the kernel which interpreter to use. The script is then read line by line and executed exactly as if typed. The shell's expressive power comes from this seamless equivalence between interactive use and scripted use — what works at the prompt works in a script and vice versa, which is why shell skill scales from one-liners through ten-thousand-line deployment systems.