A terminal is an environment for text input/output. Inside the terminal, one runs command-line and text mode programs (including shells).
A terminal is an environment for text input/output. Inside the terminal, one runs command-line and text mode programs (including shells).
This tag is about terminals in general; for the Mac OS X Terminal application, use osx-terminal.
Don't confuse the terminal, which is the environment for text mode programs, with the shell, which executes commands. See also command-line if your problem is accomplishing a task on the command line.
Background
In a unix context, a terminal is an environment for text input and output. Historically, a terminal was a physical device, but these days most terminals are provided by terminal emulators.
If your display is in text mode, this is usually known as a “text console”, or sometimes (somewhat confusingly) as a “virtual terminal”.
A “terminal” can be graphical, but in a unix context there will normally be a qualifier, e.g. “X terminal”.
Most interactive programs run inside terminals are of one of two kinds:
- read-eval-print loops are programs that read a line, then execute it. Unix shells are examples of this.
- full-screen text mode programs, such as
emacs -nw
,lynx
,nethack
,vi
, …
Escape sequences
A terminal and the program inside it communicate by exchanging text with embedded escape sequences. When you type a character in a terminal, the program receives that character; if you type a function key, the terminal usually converts it to an escape sequence. In the other direction, if the program outputs a printable character, the terminal displays it; if the program outputs a control character, it performs a function such as moving the cursor, changing the color, etc. Most terminals are compatible with Xterm control sequences.
Further reading
- What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?
- What protocol/standard is used by terminals?
- Is screen useful?
- How can I close a terminal without killing the command running in it?
- Is it possible to configure Bash so that STDERR can be a different color than STDOUT?
- How to unfreeze after accidentally pressing Ctrl-S in a terminal?