Questions tagged [terminal]

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

4002 questions
1508
votes
10 answers

What is the exact difference between a 'terminal', a 'shell', a 'tty' and a 'console'?

I think these terms almost refer to the same thing, when used loosely: terminal shell tty console What exactly does each of these terms refer to?
Lazer
  • 33,497
  • 24
  • 68
  • 74
901
votes
3 answers

How to unfreeze after accidentally pressing Ctrl-S in a terminal?

It's a situation that has happened quite often to me: after I press (with a different intention) Ctrl-S in a terminal, the interaction (input or output) with it is frozen. It's probably a kind of "scroll lock" or whatever. How do I unfreeze the…
imz -- Ivan Zakharyaschev
  • 14,533
  • 12
  • 58
  • 118
555
votes
7 answers

Scroll inside Screen, or Pause Output

I use screen for my command-line tasks while managing the servers where I work. I usually run small commands (mostly file-system tasks) but sometimes I run more extensive tasks (like DBA). The output of those tasks is important to me. Since I use…
AeroCross
  • 6,083
  • 4
  • 16
  • 7
538
votes
9 answers

How to display `top` results sorted by memory usage in real time?

How can I display the top results in my terminal in real time so that the list is sorted by memory usage?
Theodor Coogan
  • 5,381
  • 3
  • 11
  • 3
433
votes
11 answers

How can I run a command which will survive terminal close?

Sometimes I want to start a process and forget about it. If I start it from the command line, like this: redshift I can't close the terminal, or it will kill the process. Can I run a command in such a way that I can close the terminal without…
Matthew
  • 5,187
  • 4
  • 18
  • 11
375
votes
2 answers

Ctrl-s hangs the terminal emulator?

I came across a sentence in vimdoc: Note: CTRL-S does not work on all terminals and might block further input, use CTRL-Q to get going again. and using CTRL-S indeed hangs my vim. I was thinking that it was vims fault, since there…
Hongxu Chen
  • 5,769
  • 7
  • 24
  • 32
322
votes
10 answers

How to split the terminal into more than one "view"?

From vi, if you issue the command :sp, the screen splits into two "views", allowing you to edit more than one file from the same terminal. Along those same lines, is there a way to have multiple shells open in the same terminal?
Justin Ethier
  • 16,416
  • 9
  • 41
  • 55
251
votes
7 answers

List all connected SSH sessions?

I just SSH'd into root, and then SSH'd again into root on the same machine. So I have two windows open both SSH'd into root on my remote machine. From the shell, how can I see a list of these two sessions?
themirror
  • 6,698
  • 11
  • 29
  • 34
244
votes
9 answers

What causes this green background in ls output?

There are two directories shown by 'ls'. Normally directories anywhere are blue on black background. But the first one is blue on green and impossible to read. Why is this? How to make it blue on black, or at least something light on something…
DarenW
  • 3,243
  • 5
  • 17
  • 20
230
votes
10 answers

Terminal prompt not wrapping correctly

I have an issue where if I type in very long commands in bash the terminal will not render what I'm typing correctly. I'd expect that if I had a command like the following: username@someserver ~/somepath $ ssh -i…
Muricula
  • 2,410
  • 2
  • 11
  • 6
214
votes
12 answers

How to scroll in a terminal using keyboard?

How can I scroll in bash using only the keyboard? If it's not possible in bash, are there any other shells that support this?
Kshitiz Sharma
  • 8,255
  • 20
  • 53
  • 73
213
votes
7 answers

delete line in vi

How can I delete a line in VI? Here what I am doing right now: Open up the terminal alt + ctrl + t vi a.txt I move my cursor to the line which I wan to delete, then what key-combination is should use to delete line in vi editor?
I-M-JM
  • 2,241
  • 2
  • 14
  • 5
189
votes
4 answers

What is the point of Ctrl-S?

Ctrl+S stops all output to the terminal which can be restarted with Ctrl+Q. But, why does Ctrl+S exist in the first place? What problem was trying to be solved by putting that control sequence in place?
Jeff King
  • 2,025
  • 2
  • 14
  • 8
187
votes
9 answers

How can I disown a running process and associate it to a new screen shell?

I have a running program on a SSH shell. I want to pause it and be able to unpause its execution when I come back. One way I thought of doing that was to transfer its ownership to a screen shell, thus keeping it running in there. Is there a…
levesque
  • 3,565
  • 5
  • 19
  • 15
165
votes
9 answers

Fix terminal after displaying a binary file

I'd tried command cat with an executable file: cat /bin/ls Now I can't read any word in this terminal (Linux console). How can I fix it?
lotusirous
  • 3,539
  • 5
  • 16
  • 10
1
2 3
99 100