How to reset a broken TTY?

15

3

My Slackware TTY can be broken easily by running:

cat some_binary_file

After the command, the entire TTY will no longer display readable characters but still responds to keyboard events.

Even if I logout and login again, the TTY is still broken and does not show readable characters anymore. I must restart the machine to restore normal TTY operation.

Is there a solution without restarting entire machine?

Howard

Posted 2013-09-03T10:58:49.873

Reputation: 1 646

Answers

13

Run echo ^v^o, that is echo and then Ctrl-v and then Ctrl-o, Enter. You will not see the Ctrl-v. It will display as echo ^O. Ctrl-v sets it into verbose mode, passing through control characters, and the Ctrl-o will reset the terminal.

Florian

Posted 2013-09-03T10:58:49.873

Reputation: 403

This doesn't work for me on MacOSX (10.11.6) / iTerm2 (3.0.12) / bash (4.1.2) – Ed Randall – 2017-02-08T13:45:42.710

4Just a short hint: If the TTY is completely unusable or a logging console you can reset it easily from any other TTY with echo ^v^o > /dev/ttyN where N is the number of the terminal. – Torben – 2014-02-24T11:52:26.860

25

Usually, running reset resets the terminal. Some key bindings from .inputrc might be lost, though.

choroba

Posted 2013-09-03T10:58:49.873

Reputation: 14 741

Super simple solution that fixed my crashed tmux oh-my-zsh pane. – Shadoninja – 2016-05-10T23:14:13.640

This is better than the accepted answer in my opinion. When you cannot see what you are typing is easier to type reset and hit enter than trying to use key combinations, plus, it works 100% of the times. – Sergio – 2019-10-25T11:12:31.887

12

You can try the ANSI reset command:

printf "\033c"

jlliagre

Posted 2013-09-03T10:58:49.873

Reputation: 12 469

this is the only one that worked on OpenBSD 5.4 – execNext – 2014-10-01T01:55:30.770

1This also worked from the shell (bash) as echo -e '\033c' – Ed Randall – 2017-02-08T13:43:17.750

3@EdRandall Yes. Note that "echo -e" is not supported by all shells while printf has the advantage of being portable so works whatever the shell, including bash. – jlliagre – 2017-02-08T14:53:23.147

I imagine that this has nothing to do with the seagull diacritic in IPA? U+033C ‹◌̼› \N{COMBINING SEAGULL BELOW} – TRiG – 2017-07-03T14:14:43.450

@TRiG Indeed. Nothing to do either with the famous Eric Cantona's quote. ;-)

– jlliagre – 2017-07-03T14:34:02.280

5

My terminal didnt display any characters I typed. None of the other tricks worked. This one works:

stty sane

Worked for me. I sometimes have a terminal in an unresponsive state, but none of the other suggestions could give me the output back again. The other suggestions I tried, but didn't work:

echo ^v^o
reset
printf "\033c"

Source: https://unix.stackexchange.com/a/79686/53236

Jesper Rønn-Jensen

Posted 2013-09-03T10:58:49.873

Reputation: 5 450

0

There are actually a few potential problems, and it might have to do with your environment. First off, as @Jesper answered, you want to do stty sane. However, you might not even be able to set up the environment correctly with that.

This is due to the difference between /bin/bash and /bin/sh. Upon opening your tty, run /bin/bash and then try stty sane. This should fix everything. Finally, I recommend adding such a thing to .bashrc

Another option would be to install a sane tty software.

user2262111

Posted 2013-09-03T10:58:49.873

Reputation: 101