People say "terminal", "shell" and "console" as if they were the same thing, and most of the time nobody minds. They're different pieces, though, and knowing which one does what makes a lot of strange errors easier to read. Here's a small glossary of the words that keep showing up around the command line.
Terminal. The program you type into. It shows text, passes your keystrokes along and draws whatever comes back. On its own, it doesn't understand a single command.
Shell. The program that does understand them. It reads a line, works out what you meant and runs it. Bash, Zsh and Fish are shells, and so is the old sh. When a tutorial says "type this in the terminal", the shell is the one doing the work.
TTY. Short for teletypewriter. The first Unix terminals were machines that printed on paper,1 and the name stuck to every terminal device the system knows about. They live in /dev, and the text consoles you reach with Ctrl+Alt+F1 to F6 on many Linux distributions are /dev/tty1, /dev/tty2 and so on.
PTY. A pseudoterminal, a terminal that exists only in software. It's a pair of connected ends: the shell talks to one end as if it were a real TTY, and another program sits on the other end and takes care of the screen. Every window of a terminal emulator, every SSH session and every pane in tmux is a PTY.2
CLI. Command-line interface. A program you use by typing a command with its options and reading the answer, like ls -la or git log. It runs, prints and exits.
TUI. Text user interface. A full-screen program drawn with characters, with menus, panels, colors and a cursor you move around. htop, Vim and Midnight Commander are TUIs. They run inside the terminal and stay open until you leave them.
TERM. An environment variable that tells programs which kind of terminal they're talking to, like xterm-256color. Programs don't guess what your terminal can do. They read TERM and look it up.
Terminfo. The place where they look it up. It's a database with one entry per terminal type, describing how to clear the screen, move the cursor, use colors and so on. If TERM names a type the database doesn't know, things break in odd ways: wrong colors, keys that do nothing, or a plain "unknown terminal type".3
A few commands show these pieces from the inside:
$ tty /dev/pts/0 $ echo $TERM xterm-256color $ tput colors 256 $ infocmp | head -2 # Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm-256color xterm-256color|xterm with 256 colors,
Source
$ tty
/dev/pts/0
$ echo $TERM
xterm-256color
$ tput colors
256
$ infocmp | head -2
# Reconstructed via infocmp from file: /usr/share/terminfo/x/xterm-256color
xterm-256color|xterm with 256 colors,The usual way to run into terminfo is to SSH from a newer terminal into an older server. Kitty sets TERM to xterm-kitty and Ghostty to xterm-ghostty, and a server that has never heard of them complains. Copying the entry over fixes it:
$ infocmp -x xterm-ghostty | ssh server -- tic -x -Source
$ infocmp -x xterm-ghostty | ssh server -- tic -x -Terminal emulators. The programs that play the part of the old hardware terminal on a modern desktop. A few well-known ones:
- xterm: the classic emulator of the X Window System, from 1984 and still maintained.
- Kitty: drawn on the GPU, with its own protocol for showing images inside the terminal.
- Alacritty: also GPU-accelerated, written in Rust and minimal on purpose, leaving tabs and splits to the window manager or to tmux.
- WezTerm: Rust and GPU as well, with a multiplexer built in and a configuration written in Lua.
- Ghostty: written in Zig, with a native interface on macOS and on Linux.
P.S. Today I also spent the whole day organizing everything I host and make available. Some services need authentication, but all you have to do is ask me. Others are open to anyone. There are 160 in total, and most of them are at thatsmy.tools.
Notes
Teleprinters like the Teletype Model 33, which typed every line onto a roll of paper. Linux still calls the part of the kernel that handles terminals the TTY layer. ↩
On Linux each new pseudoterminal shows up as
/dev/pts/0,/dev/pts/1and so on, and thettycommand prints the one you're in. ↩Older systems kept this in a single text file called termcap. Terminfo replaced it with compiled entries, and
infocmpturns an entry back into text. ↩