If I run

read -r -s INPUT

And then interrupt it with Ctrl-C, then the terminal stays in a state where all the input characters are not shown.

How can I restore the terminal after such an incident?

  • Interestingly, I cannot duplicate this with either version 4.3 or version 4.4 of the Bourne Again shell. – JdeBP Feb 8 at 14:12
  • Yeah, I am using bash 3.2 – Ross MacArthur Feb 9 at 8:11

The command used to reset the terminal is aptly named:


However, this would likely clear the terminal as well.

You may also try

stty echo

which would turn on echoing of what you type, or

stty sane

which should get your terminal back into a sane state.

If the Enter key does not seem to work, you may use Ctrl+J instead.

  • 1
    In some cases it may be necessary to use <CTRL-J>reset<CTRL-J> instead of pressing the <Enter> or <Return> key as usual. <CTRL-J>stty sane<CTRL-J> might also be used if the terminal is in some strange state. – Bodo Feb 8 at 13:03
  • 1
    stty echo worked for me. I used trap 'stty echo && exit 1' SIGINT – Ross MacArthur Feb 8 at 13:04
  • It's unlikely to be a strange state, Bodo, or anything approaching needing even stty sane let alone reset (which is overkill). The action of the -s option to read is both simple and documented. – JdeBP Feb 8 at 14:16
  • @Bodo not in this case -- bash's readline will NOT turn off icrnl, and if some hobgoblin has taken over your tty, he may just as well do a stty -icrnl inlcr (and the advice from the end of the answer is useless). But it's quite curious how the OP got there -- bash's readline should reset the term itself upon SIGINT and turn echo back on. – Uncle Billy Feb 8 at 16:23
  • And it does. – JdeBP Feb 8 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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