I never really understood how a terminal emulator (be it e.g. XTerm or the Linux virtual console) works. What transformations happen to the input (key up/down events) to produce the output (usually the standard input of the application that is running in the terminal, a signal being sent and so on)? What is actually the input for the terminal and what is already handled by the input drivers (in the kernel, X server, ...). How and where do the terminal capabilities databases like terminfo or termcap enter this process? How are "special" keys like arrows processed? And conversely: how does it work the other way round: application standard output/error &rarr; medium (screen, paper)?
11438
Suppose I press the A key in a text editor and this inserts the character a in the document and displays it on the screen. I know the editor application isn't directly communicating with the hardware (there's a kernel and stuff in between), so what is going on inside my computer?
116330
I need a C code to be executed when some particular keys are pressed in Linux "Desktop" environment.  What are the ways to register for such an event and How?  Should I write ISR for that? I need an exact part of Linux from where I can get this call.  Which part of OS handles stuff like these, Is it part Desktop environment like GNOME or part of some service?
72586
In a virtual terminal I (accidentally) pressed Win+1 and got a new line consisting of  (arg: 1)   As long as I keep Win pressed, all numbers I press get appended to the number in the parentheses, e.g. Win and 1+4 yields (arg:14).  When I (after releasing Win) press any key, that character is printed as many times as the number reads and the (arg: ...) expression is replaced by the standard prompt.  Does anybody know what happens here?
72006
I've noticed that SyncTERM uses a different character encoding than the default MacOS terminal emulator, and they're incompatible with one another.  For example, say you want to print a block character in a format string.  In SyncTERM, which uses the IBM Extended ASCII character encoding, you would use an octal escape sequence like \261.  In Terminal.app (and probably iTerm2 as well), this just prints a question mark.  Since these terminals use UTF-8, you need to use the \uxxxx escape sequence.  So let's say you want to print a certain, not-ASCII, character in a format string, and you want it to work in all terminal emulators, regardless of character set.  I'm guessing you would use an entry in the terminfo database, but I'm not really familiar with terminfo.  I need some pointers here.
107051
I am running Ubuntu Server and want to have multiple terminals. Screen works fine but..it is not user friendly. I mean..after pressing Ctrl+A you get no notification of you being in command mode, in order to display terminals you have to enter " which is not friendly at all (on my keyboard it is Shift+1), and so on..  I looked at byobu but it seems bugged: the cpu status lines keep increasing downside up and eventually cover my screen..but overall I still don't like it much.  I was searching for something with nano's graphic..with bottom part of the screen filled with instruction/status and upper part, of course, my current terminal.  Does something like that exist? Or, alternatively, can you help me fix the byobu bug?
54085
I have explored almost    , to no avail.  Let me describe the problem in detail:  I run some unattended scripts and these can produce standard output and standard error lines, I want to capture them in their precise order as displayed by a terminal emulator and then add a prefix like "STDERR: " and "STDOUT: " to them.  I have tried using pipes and even epoll-based approach on them, to no avail. I think solution is in pty usage, although I am no master at that. I have also peeked into the source code of , but that has not been much productive.   Ideally I would use  instead of Bash to accomplish this, but I have not been able to. Seems like pipes automatically forbid keeping a correct lines order because of buffering.  Has somebody been able to do something similar? Or it is just impossible? I think that if a terminal emulator can do it, then it's not - maybe by creating a small C program handling the PTY(s) differently?  Ideally I would use asynchronous input to read these 2 streams (STDOUT and STDERR) and then re-print them second my needs, but order of input is crucial!  NOTE: I am aware of  but it does not work for me with Bash scripts and cannot be easily edited to add a prefix (since it basically wraps plenty of syscalls).  Update: added below two gists       (sub-second random delays can be added in the sample script I provided for a proof of consistent results)  Update: solution to this question would also solve , as @Gilles pointed out. However I have come to the conclusion that it's not possible to do what asked here and there. When using 2&gt;&amp;1 both streams are correctly merged at the pty/pipe level, but to use the streams separately and in correct order one should indeed use the approach of  that involves syscall hooking and can be seen as dirty in many ways.  I will be eager to update this question if somebody can disprove the above.
84795
Do not run this command to 'test' it unless you are prepared for a crash and/or force-rebooting your system.  I was in my Virtualbox running 12.04 trying to compile an app, and while waiting I happened to chance upon a forum where a comment said:   Try :(){ :|: &amp; };:  Fun, too, and doesn't need root.  Without thinking, I ran it in my gnome-terminal. It made my 12.04(in Virtualbox) lag so badly, I had to shut it down. My question is what does this command do?   :(){ :|: &amp; };:
63758
What do people mean when they point out that the "keys are not properly mapped" in a Linux installation when working on the command line?  Isn't the default installation OK? What extra/specific mappings are needed?    I also was told that for my Mac where my Home and End and Ctrl keys do not do what I expected.
45475
So I echo output of my programs ran in terminal by command 2&gt;&amp;1 &gt;&gt; /path/toFile.txt  It creates few limitations that I want to overcome:   It "freezes" and gives no output in terminal - only way to see actual output is to open output file Opening output file is not giving live results. It gives results from time of opening that file     How to echo output to a file and be able to:  a) see live changes in that file (separate program would be needed I assume)  or  b) output to file and see that output in terminal in the same time
2249
Recently I installed ubuntu in my laptop for using c programming. but when I open the terminal and typed vi test.c, It open it but it will not work properly. when i pressed backspace it will not work and when i press arrow key it will print some alphabets. What will i do to work properly. please anybody help for this related problem. thank you
97275
I define a shell keybinding in my ~/.bashrc like so:  bind -x '"\e\C-w":"/usr/bin/reset"'   This does make Ctrl-Alt-w launch the reset executable. However, it leaves the terminal in a state that resembles the one you get into by pressing Ctrl-v. So, for example, if immediately after resetting in this way I press Ctrl-p, instead of invoking the action of that shortcut (repeat previous command) I get ^P printed.  Any idea what's causing this problem and how to fix it?  EDIT: I am attaching a Python program that reproduces the messed-up terminal state I am trying to fix with the reset. I encounter this condition very often while debugging multi-threaded applications:  import pdb, thread, time  def interrupt():     time.sleep(2)     pdb.set_trace()  thread.start_new_thread(interrupt, ()) raw_input('? ')   To reproduce the messed-up state, just run the code above, and press Enter when you see the debugger invoked (it will print a bunch of text, ending with pdb.set_trace(), about two seconds after you run the program and the initial prompt appears).
87853
I've been using ubuntu for like 3 years as my main os. I've used terminal many many times but never have I deeply understand it. I run commands, I'm familiar with the basic ones, but i want to dig deeper. Is there any video introduction(i like to lay back and watch tutorials instead of reading books) to novice-intermediate to advanced command line?   Thank you.
84088
Can I see images and watch movies inside the terminal emulator? In case of virtual console I can do it via framebuffer, but what about terminal emulators?
13591
I am confused about how Ctrl-key combinations work in terminal. In bash man page, there are various combinations such as:   C-e - go to end of the line C-f - go one character forward   etc.  But then there are some undocumented shortcuts such as:   C-j (OR C-m) for return key. C-h for backspace C-i for tab etc.   Are these shortcuts just forgotten to be documented? Or, because   C-j is LF C-m is CR C-i is Tab   in ASCII, is this somehow a "default" behavior? In other words, is the behavior for C-j, C-m and C-i not implemented by bash but by something else?  Another question is, when I press C-v and left arrow key, ^[[D appears on screen. I.e, ESC-[-d. But when I press ESC-[-d, the cursor does not move left. What is the reason for this?  EDIT:  Initially, I have thought that when I press C-j, the keyboard directly sends 00001010 to kernel. But then I decided that this is not the case, because using programs such as xev or evtest, I have observed that key presses to Control and j appear as different events. So when I press C-j, the keyboard does not send 00001010, but probably multiple bytes. Then where the conversion of these multiple bytes to 00001010 is done?
121596
Is there some way of saving all the terminal output to a file with a command?   I'm not talking about redirection command &gt; file.txt Not the history history &gt; file.txt, I need the full terminal text Not with hotkeys !   Something like terminal_text &gt; file.txt
78059
Example: In a Terminal command xdpyinfo | grep resolution (that I have taken from an answer), does the | character mean that the xdpyinfo output shall be sent to the grep program input for printing a line containing the resolution string? Where should I seek for such an information to avoid filling this forum by too simple questions? Thanks.
60857
I just ran across a screenshot of someone's terminal:    Is there a list of all of the characters which can be used in a Bash prompt, or can someone get me the character for the star and the right arrow?