I use PuTTY in order to SSH to some Ubuntu 14.04.4 LTS x64 server. Pressing the key ENTER causes the terminal to go to a new line. However, from time to time, some program outputs some text, and afterward pressing the key ENTER doesn't causes the terminal to go to a new line anymore (see demonstration below).

enter image description here

Is there any way to prevent that, or at least when pressing the key ENTER doesn't causes the terminal to go to a new line anymore, is there anyway to reset the terminal so that ENTER causes the terminal to go to a new line again?

  • 2
    Franck - When that happens, press Ctrl+C, and then type in reset and press Enter. Let me know if that helps any. – Pimp Juice IT Oct 16 '17 at 4:14
  • @Facebook Thanks, type in reset and press Enter works! – Franck Dernoncourt Oct 16 '17 at 4:24
  • Also, file a bug report against that glances program for leaving the terminal in a bad state after crashing ;) – marcelm Oct 16 '17 at 10:25
  • By coincidence, a similar question just turned up on Unix & Linux Stack Exchange: unix.stackexchange.com/questions/398291 – JdeBP Oct 16 '17 at 11:25
  • Consider using cygwin and installing Terminal. Putty is very awful. For example, mc won't display correctly and won't let you select files with shift. – JorgeeFG Oct 16 '17 at 19:10

You can use the reset command by typing in reset then pressing Enter when that occurs to reset the terminal so it'll go to a new line when pressing Enter again.


ubuntu@db200krctc:~$ ubuntu@db200krctc:~$ ubuntu@db200krctc:~$ ubuntu@db200krctc:~$
ubuntu@db200krctc:~$ reset

Further Resources

  • reset

    When invoked as reset, tset sets cooked and echo modes, turns off cbreak and raw modes, turns on newline translation and resets any unset special characters to their default values before doing the terminal initialization described above. This is useful after a program dies leaving a terminal in an abnormal state.

| improve this answer | |

The reset command does more than you really need here in this particular case, as your problem is merely that echo has been turned off. reset actually emits control sequences to reset the terminal itself, when all that you actually need is to reconfigure the line discipline within the operating system kernel, turning echo mode back on, and not touch the terminal at all.

For that, simply use:

stty sane
or even just:

stty echo

reset addresses situations when it is actually the terminal's own state that needs resetting and not (just) the state of the line discipline; i.e. the tabstops have been erased, the terminal is left switched to the alternative screen buffer, an inconvenient 8-bit character set has been swapped in, and so forth.

Further reading

| improve this answer | |
  • How is line discipline actually in the kernel? This answer sounds right to me except that part of which I am very dubious. – Stephen Ostermiller Oct 16 '17 at 12:01
  • @StephenOstermiller: Where else would it be? – psmears Oct 16 '17 at 12:12
  • 3
    The line discipline is actually one of the first kernel drivers ever that were configurable from userspace, Unix had stty and gtty (set and get) system calls long before they were superseded by the more general ioctl call. – Guntram Blohm supports Monica Oct 16 '17 at 12:24
  • 6
    It makes sense because it's then independent of the shell, so it'll work in other programs too. And in the early days there was no terminal program so to speak - serial consoles would interact directly with the kernel (and indeed still can). – Muzer Oct 16 '17 at 13:44
  • 1
    To clarify: In the olden days the back side of /dev/tty was a physical serial port. The line discipline was managed by the kernel tty driver. With a fake terminal session or a network terminal session, /dev/tty is a psuedo-terminal and it's back side is not a physical serial port but another pseduo master device from which session data is read/written and fed to the network socket or the terminal emulator. The /dev/tty side of the pseudo terminal behaves much the same as the /dev/tty side of a real serial port. en.wikipedia.org/wiki/Pseudoterminal – Sam Liddicott Oct 17 '17 at 11:04

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.