A terminal is where text enters and leaves a session; a shell interprets a command language. They often appear together, which makes their names easy to confuse. TTY and console describe related interfaces and roles rather than more powerful kinds of shell.
This revises my original Chinese explanation. The terms below use the Unix-like operating-system context.
| Term | Role | Example |
|---|---|---|
| Terminal | An interface for text input and output; originally hardware, now often emulated in software | A terminal-emulator window |
| Shell | A program that interprets commands and runs builtins or other programs | Bash or Zsh |
| TTY | The operating system's terminal abstraction; the name comes from teletype | A virtual terminal or a pseudoterminal slave |
| Console | An interface designated for system interaction or messages | A Linux system console or serial console |
A limited analogy
Think of an office service window. The terminal is the window through which requests and replies pass. The shell is a clerk who understands a particular command language and either handles a request directly or starts the appropriate program. The operating-system kernel provides the underlying facilities those programs use.
The kernel does not normally parse a command such as ls -l as shell language. The shell parses it and starts a program; that program requests operating-system services through system calls. Commands such as cd are commonly shell builtins, executed inside the shell itself. See the Bash manual's account of builtins.
The analogy stops there. A console is not a “royal window” whose user automatically has greater privileges. Permissions depend on the process, user, and system policy. An ordinary terminal can contain an administrative shell, and a console can require an ordinary login.
How the pieces fit
A common graphical-terminal session has this path:
keyboard and display
↕
terminal emulator
↕
pseudoterminal (PTY)
↕
shell or another terminal programA PTY is a pair of software endpoints. The emulator handles one side; the shell and programs see a terminal interface on the other. A shell can also run a script without any terminal, and a terminal can run an editor or another program without an interactive shell.
On Linux, the system console has a particular role in system messages and administration; it may be associated with a virtual terminal or a serial device. The kernel's serial-console documentation illustrates those configurations.
中文版
在类 Unix 系统中,terminal(终端) 提供文本输入输出接口;shell 是解释命令语言的程序。两者经常一起使用,但不是同一个东西。
可以把终端想成办事窗口,把 shell 想成理解命令的办事员。shell 解析命令后,执行内部命令或启动其他程序;程序再通过系统调用使用内核提供的服务。内核通常不会直接把 ls -l 当作 shell 命令来解释。
TTY 源自 teletype(电传打字机),现在也用于指操作系统的终端抽象。图形终端模拟器通常通过 PTY(伪终端) 与 shell 或其他终端程序连接。
Console(控制台) 强调系统交互或系统消息等用途,例如 Linux 的系统控制台或串口控制台。它不是“权限更高的终端”:权限取决于登录身份、进程和系统策略。普通终端里可以运行管理员 shell,控制台也可以要求普通的登录认证。
shell 可以不依赖终端执行脚本;终端也可以直接运行其他程序。区分“输入输出接口”“命令解释程序”和“系统指定用途”,比把它们排列成权限等级更准确。