32

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

6 Answers6

59

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

choroba
  • 20,299
26

You can try the ANSI reset command:

printf "\033c"
jlliagre
  • 14,369
24

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
  • 533
16

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

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.

0
    import subprocess
    def clear():
    if name == 'nt':
            _ = system('cls')
    else:
            _ = system('clear')
            subprocess.run(["reset"])

This works for me, my shell is /bin/bash, my enviroment is Windows 11, SWL and Python 3.8