32

After having played with curl, a binary file has been dumped inside my terminal. For example, the horizontal lines: ─ I use to format my prompt are replaced by 'q', and it can be much worse.

Why does this happen, and how can you fix it without having to close the terminal ?

alecail
  • 1,623

3 Answers3

39

I think reset would definitely fix it.

Consider looking into man page.

Example:

[m0nhawk@terra:~]> cat /dev/urandom
êIÉè;┤Ü)MåÇ▐¿÷¢§ôWdO┘&!π¡
[└█┼░▒┬┐@├err▒:·]> c▒├ /de┴/┤r▒┼do└

And resetfixes this.

m0nhawk
  • 2,627
  • 3
    Worth to mention, if you run cat /dev/urandom, abort with Ctrl-C. Also, @Antoine, you could examine clear. I know you said "terminal", but, in the Linux console, there is (besides clear and reset) clear_console as well. – Emanuel Berg Oct 13 '12 at 13:24
  • 5
    In some cases, reset has been known not to solve this. echo -e '\017' can help there. – Alexios Oct 13 '12 at 15:53
  • "some cases" basically refers to those where the terminal description is incorrect. – Thomas Dickey Feb 22 '16 at 10:09
  • reset does more than that, it resets everything to defaults. Afterward you might find yourself in a terminal with unusable "width"
    The mentioned "stty sane" command does the job better
    – John Sep 23 '16 at 21:43
  • In many cases echo -e '\017' is the solution like Alexios said, most other suggested commands like reset or stty can do more harm than good. – John Feb 28 '20 at 04:00
  • when I'm connected over SSH (I use Bitvise) only Alexios solution fixes for me echo -e '\017', nothing else would work – JohnRDOrazio Jul 28 '20 at 00:00
10

Typing the command stty sane should fix it.

Renan
  • 17,136
efutch
  • 173
5

Best solution I've found is:

echo <ctrl-v><esc>c<enter>

I alias this to "unbinary"

jasonwryan
  • 73,126
  • 1
    For a terminal emulator, sure. But a full reset on a hardware terminal (or serial connection) is a little drastic (you would have to log in again). – Thomas Dickey Feb 22 '16 at 10:11
  • worked for me when stty sane did nothing & reset changed width to default and still had a wierd char – Stefan Rogin Oct 05 '16 at 14:21