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).

Filter by
Sorted by
Tagged with
1530 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?
  • 34.1k
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, ...
  • 3,635
239 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 ~/...
  • 2,500
93 votes
15 answers

Removing control chars (including console codes / colours) from script output

I can use the "script" command to record an interactive session at the command line. However, this includes all control characters and colour codes. I can remove control characters (like backspace) ...
  • 1,041
444 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 ...
  • 5,337
252 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 ...
  • 3,333
86 votes
4 answers

What are the responsibilities of each Pseudo-Terminal (PTY) component (software, master side, slave side)?

I am trying to figure out how a tty works1 (the workflow and responsibilities of each element). I have read several interesting articles about it, but there are still some blurry areas. This is what I ...
  • 2,169
77 votes
2 answers

Output from ls has newlines but displays on a single line. Why?

I think I may be overlooking a relatively fundamental point regarding shell. Output from the ls command by default separates output with newlines, but the shell displays the output on a single line. ...
925 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 "...
103 votes
3 answers

What is stored in /dev/pts files and can we open them?

According to my knowledge, /dev/pts files are created for ssh or telnet sessions.
  • 3,429
83 votes
6 answers

Can I configure my shell to print STDERR and STDOUT in different colors?

I want to set my terminal up so stderr is printed in a different color than stdout; maybe red. This would make it easier to tell the two apart. Is there a way to configure this in .bashrc? If not, is ...
  • 37.8k
5 votes
2 answers

Why `clear` do not clear whole screen?

When I use clear command to clear the screen. It is not cleared (see screenshot when I scroll up a bit after command done) So I double the command to get right behavior: $ clear && clear &...
151 votes
5 answers

How do I attach a terminal to a detached process?

I have detached a process from my terminal, like this: $ process & That terminal is now long closed, but process is still running, and I want to send some commands to that process's stdin. Is ...
  • 5,930
15 votes
2 answers

Execute command in remote active terminal

Suppose you have a terminal emulator (T1) open with a PID of 6350. From another terminal, type this command (C1): echo "ls\n" > /proc/6350/fd/0 This writes ls and the new line in T1 but does not ...
  • 151
100 votes
4 answers

Save all the terminal output to a file

Is there some way of saving all the terminal output to a file with a command? I'm not talking about redirection command > file.txt Not the history history > file.txt, I need the full terminal ...
user avatar
10 votes
2 answers

Why (and how) did using cat on binary files mess up the terminal?

If I understand the cat manual correctly: concatenate files and print on the standard output cat will take files as argument and print them on standard output. What I don't get is if I use the ...
  • 9,245
170 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?
  • 3,589
60 votes
8 answers

How can I hook on to one terminal's output from another terminal?

I need to hook onto output of currently running terminal (tty1) from virtual terminal and capture it (running X server).
21 votes
3 answers

How does a program decide whether or not to have coloured output?

When I execute a command from a terminal that prints coloured output (such as ls or gcc), the coloured output is printed. From my understanding, the process is actually outputting ANSI escape codes, ...
10 votes
2 answers

Is it the process that has a controlling terminal, or is it the session that has a controlling terminal?

When we say that a process has a controlling terminal, do we mean that the process itself has a controlling terminal, or is it the session that the process belongs to that has a controlling terminal? ...
  • 375
3 votes
1 answer

What type of terminal to support if implementing a terminal emulator? [closed]

I have heard that VT100 is the de facto standard. Does it mean if I can just support VT100 and then my terminal can work for existing commandline applications without big problems? If not, how to make ...
  • 31
67 votes
3 answers

tmux, TERM and 256 colours support

Introduction My question arises from the necessity of understanding why I have now (after multiple trials) Terminal and tmux supporting 256 colours and tput colors telling me there are only 8 of them....
  • 1,573
47 votes
3 answers

Where does the TERM environment variable default get set?

When I open a terminal window with the GNOME Terminal emulator in the desktop GUI the shell TERM environment variable defaults to the value xterm. If I use CTL+ALT+F1 to switch to a console TTY ...
30 votes
7 answers

"Friendly" terminal color names in shell scripts?

I'm aware of libraries in languages such as Ruby and Javascript to make colorizing your terminal scripts easier by using color names like "red". But is there something like this for shell scripts in ...
  • 6,818
30 votes
1 answer

What protocol/standard is used by terminals?

I was wondering how the "GUI" of a command line application is communicated over a network. Most of the time, it's quite simple (plain text / input) but sometimes it's more complex (aptitude). Is it ...
2 votes
2 answers

What is switching environments on the system wide terminal called?

I am currently trying to make an autonomous drone using the Robot Operating System (ROS). To do this, I have installed Raspbian Lite (Jessie) on a Raspberry Pi 3 and am currently using ROS Kinetic on ...
  • 285
328 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 ...
196 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 ...
  • 2,095
76 votes
6 answers

How to check if Bash can print colors

I want to know if there's any way to check if my program can output terminal output using colors or not. Running commands like less and looking at the output from a program that outputs using colors, ...
62 votes
2 answers

Documentation on LESS_TERMCAP_* variables?

I see these pretty colors in manpages viewed with less when setting a bunch of these variables. What do they mean, where is the documentation? Is this interpreted by less or termcap? screenshot
  • 723
55 votes
9 answers

Unable to stop a bash script with Ctrl+C

I wrote a simple bash script with a loop for printing the date and ping to a remote machine: #!/bin/bash while true; do # *** DATE: Thu Sep 17 10:17:50 CEST 2015 *** echo -e "\n*** DATE:"...
  • 713
28 votes
6 answers

key bindings table?

Do we have a key bindings table that translates all the various ways of referring to a key press? I'm using zsh, but I presume that if there was such a table it would work for any shell. The reason I ...
  • 2,045
27 votes
4 answers

Can I configure bash to execute "clear" before every command typed in the console?

I would like to configure bash to execute clear command every time I type some command in the terminal (before executing my command). How can I do that? I'm using Debian Linux.
  • 11.8k
7 votes
1 answer

How do I come by this pty and what can I do with it?

It seems that a simple shell redirect from /dev/ptmx gets me a new pseudo-terminal. $ ls /dev/pts; ls /dev/pts </dev/ptmx 0 1 2 ptmx 0 1 2 3 ptmx It disappears as soon as the process that ...
  • 57k
113 votes
11 answers

How to solve the issue that a Terminal screen is messed up? (usually after a resizing)

Sometimes, a terminal screen is messed up, and when we use man ls to read the manpages, or press the UP arrow to go to previous commands in history, the screen will show characters not as the right ...
  • 2,869
83 votes
2 answers

Clear / erase a mistyped invisible password on a shell / terminal in Linux

One thing that annoys me using Linux's terminal is when I have to type a invisble password, like when you run ssh. Sometimes I mistype one or more letters and then I have to press backspace key a few ...
64 votes
5 answers

Where do I find a list of terminal key codes to remap shortcuts in bash?

For example: "\e[1;5C" "\e[Z" "\e-1\C-i" I only know bits and pieces, like \e stands for escape and C- for Ctrl, but what are these numbers (1) and letters (Z)? What are the ;, [ and - signs for? ...
  • 2,328
43 votes
3 answers

How do some tools (e.g. nano , less) manage to leave no content in terminals after exit? [duplicate]

Whenever I use a pager like less or an editor like nano in the shell (my shell is GNU bash), I see a behaviour I cannot explain completely and which differs to the behaviour I can observe with other ...
32 votes
2 answers

What’s the difference between a “raw” and a “cooked” device driver?

Does this concept only apply to terminal drivers (which is what most sites cover) or to any driver in general?
  • 430
25 votes
2 answers

Ctrl+D for ending terminal line input

If I do $ cat > file.txt textCtrl-DCtrl-D Question 1: If I don't press enter, why do I have to press Ctrl-D twice? If I do $ cat > file.txt pa bam pshhhCtrl-Z [2]+ Stopped ...
  • 1,035
20 votes
1 answer

Why does the `reset` command include a delay?

The reset command includes a delay, between clearing the screen and returning. This is even on the latest terminal type xterm-256color. Why? man reset does not mention a delay, only the printing of ...
  • 46.8k
13 votes
1 answer

How to configure screen-restore in a terminal?

Depending on the terminal/environment following sequence has different effects: $ ls 1 2 $ man ls enter q Either I see last displayed man-page screen above the current prompt or the ls output and ...
  • 55.2k
570 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 ...
  • 6,233
256 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 ...
  • 6,818
160 votes
5 answers

How to find application's path from command line?

For example, I have git installed on my system. But I don't remember where I installed it, so which command is fit to find this out?
  • 2,295
159 votes
21 answers

How can I set my default shell to start up tmux

I would like my default bash shell to go straight into tmux instead of my always having to type tmux every time.
101 votes
3 answers

How to signal the end of stdin input

In Bash, I learned that the ending signal can be changed by here document. But by default how can I signal the end of stdin input? I happened to find that with cat and chardet, their stdin inputs can ...
  • 95.9k
60 votes
7 answers

Why do Vim colors look different inside and outside of tmux?

Environment: Fedora 25 (4.9.12-200.fc25.x86_64) GNOME Terminal 3.22.1 Using VTE version 0.46.1 +GNUTLS VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Feb 22 2017 16:26:11) tmux 2.2 I recently started ...
40 votes
1 answer

What happens when Ctrl + Alt + F<Num> is pressed?

I am looking for an explanation of what happens in Linux when this key combination is pressed to change the current terminal. In particular, what software component intercepts this key combination and ...
  • 547
37 votes
7 answers

How can I close a terminal without killing its children (without running `screen` first)?

sometimes I run an app in the gnome-terminal, but then I suddenly have to restart gnome or something. I guess the answer to the question is also useful then I want to disconnect from SSH where ...
  • 625

2 3 4 5