Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

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 .

Don't confuse the terminal, which is the environment for text mode programs, with the , which executes commands. See also 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

history | excerpt history