Take the 2-minute tour ×

If I do something like:

$ cat /bin/ls

into my terminal, I understand why I see a bunch of binary data, representing the ls executable. But afterwards, when I get my prompt back, my own keystrokes look crazy. I type "a" and I get a weird diagonal line. I type "b" and I get a degree symbol.

Why does this happen?

share|improve this question

7 Answers 7

Because somewhere in your binary data were some control sequences that your terminal interpreted as requests to, for example, change the character set used to draw. You can restore everything to normal like so:

share|improve this answer

Just do a copy-paste:

echo -e '\017'

to your bash and characters will return to normal. If you don't run bash, try the following keystrokes:


and hopefully your terminal's status will return to normal when it complains that it can't find either a or a command to run.

, or character 14, when sent to your terminal, it orders it to switch to a special graphics mode, where letters and numbers are replaced with symbols. , or character 15, restores things back to normal.

share|improve this answer
up vote 9 down vote accepted

This link has the best answer I've seen so far.

share|improve this answer

You're getting some control characters piped into the shell that are telling the shell to alter its behavior and print things differently.

share|improve this answer

VT100 is pretty much the standard command set used for terminal windows, but there are a lot of extensions. Some control character set used, keyboard mapping, etc.

When you send a lot of binary characters to such a terminal, a lot of settings change. Some terminals have options to 'clear' the settings back to default, but in general they simply weren't made for binary data.

VT100 and its successors are what allow Linux to print in color text (such as colored ls listings) in a simple terminal program.

share|improve this answer

The terminal will try to interpret the binary data thrown at it as control codes, and garble itself up in the process, so you need to sanitize your tty.


stty sane

And things should be back to normal. Even if the command looks garbled as you type it, the actual characters are being stored correctly, and when you press return the command will be invoked.

You can find more information about the stty command here.

share|improve this answer

If you really must dump binary data to your terminal, you'd have much better luck if you pipe it to a pager like less, which will display it in a slightly more readable format. (You may also be interested in strings and od, both can be useful if you're fiddling around with binary files.)

share|improve this answer
This does not answer the "why", so perhaps it should be a comment to the question. –  tzot Dec 16 '08 at 1:07

Your Answer


