So, when I cat /dev/input/mouse0 in a TTY, move the mouse around a bit, and then ctrl-z to stop cat, my terminal characters are all messed up. Almost every single character gets swapped out for another character in the ASCII character set. This same situation occurs when I execute this in Python 3.2:


The the same symptom does not appear on a shell in the GUI, only on the virtual terminals. The problem does not go away if I log out. I suspect that a certain escape code (which may be contained within the Python code) is remapping the ASCII byte codes to the character representations, but that is just a guess. What is happening and how do I undo it?

3 Answers 3


I finally found the command that I was looking for on Command Line Fu. The command is reset. I tried it, and it worked perfectly, without logging out or restarting the system.


When outputting binary files to the terminal, like your cat /dev/input/mouse0, you can send it ANY character. This can confuse the virtual terminal.

The character string ESC [ introduces a "VT100 Control sequence" (compatibility with an old glass keypunch). Other characters like ^Q, ^S, ^N, ^O do magic things based on compatibility with Model 35 Teletypes with paper tape reader/punch.

When I'm trying to de-confuse a terminal, I do:

Is output frozen? Type ^Q (ctrl-Q) (the XON character, to start the paper tape reader).

Type the command stty sane. If there are no characters echoed as you type, stty echo will restore the echo.

Read man stty, and you'll see how you can save a set of terminal settings, and restore them later!

BTW, stopping a program uses crtl-C to stop a program. Ctrl-Z just interrupts the program, in preparation for putting it in the background. Some programs catch ^C and do some necessary cleanup, file saving, etc. on the way out. If you just ^Z and run something else, this cleanup doesn't get done.

  • I have heard about using stty sane before, and have tried it. Unfortunately, the results have been the same as always: it did not work, and a restart was required to allow me to use those TTYs again.
    – fouric
    Commented Apr 14, 2012 at 3:35

reset didn't work for me.

I did $ tput init and it reset it for me.

I was runnning Debian in QEMU and did a cat of an .o file to stdout and characters went crazy. I tried $ tput init within the QEMU but it never worked.

I had to quit QEMU "CTRL-A" then x Then the character set was still messed up even though I was now in my local machine's bash.

I then typed $ tput init and the character set reset properly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .