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 ?

0

3 Answers 3

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.

6
  • 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. Oct 13, 2012 at 13:24
  • 5
    In some cases, reset has been known not to solve this. echo -e '\017' can help there.
    – Alexios
    Oct 13, 2012 at 15:53
  • "some cases" basically refers to those where the terminal description is incorrect. Feb 22, 2016 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, 2016 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, 2020 at 4:00
10

Typing the command stty sane should fix it.

0
5

Best solution I've found is:

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

I alias this to "unbinary"

2
  • 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). Feb 22, 2016 at 10:11
  • worked for me when stty sane did nothing & reset changed width to default and still had a wierd char Oct 5, 2016 at 14:21

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