In my interactive bash shell run in lxterminal's window, I don't know what I have messed up.

Typing Return key doesn't start a new line, but Ctrl-C will.

$ ^C
$ $ $ $ $ ^C
$ ^C
$ $ $ $ $ $ $ 

When I type a command, although hitting Return key will execute it, the typed command is not visible.

Before that happened, I was running some command sudo lsof ... | less (or sudo netstat ... | less), and there seemed no output, so I hit ctrl-c and/or q multiple times in an arbitrary order. When I finally got out of less, that problem with bash happened.

Did I accidentally redirect the stdout of the shell somewhere else?

I don't want to close the shell, so is there some way to fix the problem? Thanks.


I think your terminal may be stuck in a “funny” mode. You probably can reset it with the /usr/bin/reset command, that normally comes with the ncurses library.

  • Thanks. Do you know what can cause the problems (which reset can solve)? – Tim Jan 6 at 14:20
  • 7
    Commands like less use the terminal in a different way, that most commands. To do what they do, they send control codes, and escape sequences to the terminal to change its mode. The should but it back, when they are done, but if you kill less with no opportunity for it to run the reset code, then you end up where you are. Ctrl-C should send a sig int, this should be caught, and the reset code run, before exit. Sending sig kill, or bugs in less could cause the problem. – ctrl-alt-delor Jan 6 at 14:58
  • Note that sometimes the terminal is stuck so that the RETURN key doesn't work as expected. In this case control-J (^J) may work; eg ^Jreset^J – Stephen Harris Jan 8 at 1:37

If reset (proposed in another answer) does not work, try:

stty sane

maybe followed by

tput rs1

I have the following alias defined (guess I picked it up somewhere on stackoverflow):

alias   fixtty='reset; stty sane; tput rs1; clear; echo -e "\033c"'
  • In my .profile I have export sttyparms=$(stty -g) and then an alias sane=stty $sttyparms which ensures things like stty erase are restored to my values (hold over from old DEC Ultrix days where the default need not match the VT terminal setting!) – Stephen Harris Jan 8 at 1:40

As other answers suggest, simplest fix is just to run reset.

As to the cause though? This usually happens when you cat (or otherwise output) a binary file or data to your terminal.

Text is just text, and is not treated specially by the terminal, but there are also some special characters which aren't text, and are used to do things like move the cursor, clear the screen, change colour, stop echoing output, etc.

When you output binary data (rather than text), the terminal will see these special control characters and try to interpret them as they come through. You may notice the screen clears, flashes, or jumps around - this is all due to these control characters being honoured. You can experiment by running head /dev/urandom in a new terminal to see what I mean.

Most of the time, if your terminal is behaving weird in anyway, just running reset will fix it, by simply echoing all the special characters necessary to set the terminal into the basic default mode - e.g. there is a stop echoing input code and also a start echoing input code. The binary data has randomly included the former, which is why you can't see what your typing, and reset will include the latter (among others), which will fix it.

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.