This question already has an answer here:

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 ?

marked as duplicate by ilkkachu, sam, Toby Speight, Tim Kennedy, slm Mar 17 '17 at 19:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 32 down vote accepted

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.

  • 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
  • 2
    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

Typing the command stty sane should fix it.

  • Should be the accepted answer. "reset" does possibly fuck up the terminal even more, reducing it to it's defaults (screen width etc) – John Sep 23 '16 at 21:42

Best solution I've found is:

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

I alias this to "unbinary"

  • 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 5 '16 at 14:21

In addition to the answers presented here, there is also another (duplicate) post on the same topic, which some users have also found useful: Fix terminal after displaying a binary file

  • That posting was written later and provides no improvements. It should have been marked as a duplicate. – Thomas Dickey Feb 22 '16 at 10:12
  • @ThomasDickey Somehow this duplicate generates more traffic. Maybe its wording is better than mine. Do we know which term (in search engine) they used to find this other one ? – alecail Feb 22 '16 at 12:07
  • There's more words in the other (google likes words), and is not really more thorough, since there is no discussion in either of the reasons why the behavior occurs, nor of the reasons why one solution works or does not work. – Thomas Dickey Feb 22 '16 at 22:25
  • @AntoineLecaille The duplicate generates more traffic because of the accepted answer that it contains: The answer here is functional but sparse. What should you do if you can not see the cursor? which alternatives should you try if reset does not fix it? That duplicate's answer is verbose with step by step instructions. Ok, perhaps verbose does not do it for everyone, but it does seem to be generating more upvote clicks. In any case, it is my prefered answer. However, there is certainly room for both. Those preferring concise can upvote this one, instead. Freedom to choose. – Vassilis Papanikolaou Feb 23 '16 at 8:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.