0

Follow up on How to reset a broken TTY?, to fix the terminal after displaying a binary file,

I've tried all solution there, as well as those from https://unix.stackexchange.com/questions/79684/

But my case is still not covered --

  • the command clear is not clearing screen
  • using arrow-up key to see previous commands, but if there is a shorter command comes after a longer one, the longer part still remains

to reproduce the case:

cat /bin/ls
clear
# clear is not clearing screen

How to fix that?

PS, my system:

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux bullseye/sid
Release:        testing
Codename:       bullseye

$ echo $TERM
screen

I.e., it's screen session running under xterm.

xpt
  • 8,261
  • 38
  • 102
  • 156
  • I would guess that the terminal has changed modes and is not now in a 'text' mode. Read the Manual. Without knowing the brand and model, there is little that can be done. – cliff2310 Jun 22 '20 at 15:19
  • 1
    Does running `stty sane` help? – gmatht Jun 22 '20 at 15:20

1 Answers1

3

Use reset command.

Simply type reset and press Enter a few times.

If this doesn't work then your TERM environment variable is not set correctly for some reason. Try export TERM=xterm then do reset again. To permanently fix it you may need to put export TERM=xterm in your ~/.bashrc or similar.

LawrenceC
  • 73,030
  • 15
  • 129
  • 214
  • Recently installed Ubuntu 20.04: `echo $TERM` => `xterm-256color` – Hannu Jun 22 '20 at 16:56
  • See also: https://unix.stackexchange.com/questions/198794/where-does-the-term-environment-variable-default-get-set – Hannu Jun 22 '20 at 17:05
  • I've update my OP with more info, mainly, I'm having `screen` session running under `xterm`. I tried reset, then `export TERM=xterm` then do `reset` again. but it is still not working. So I suspend `screen`, did above again, and reconnect to `screen`, and now it is working as expected. thanks – xpt Jun 22 '20 at 19:07
  • Ops, my BS is still not working, under the old screen session, regardless what I tried. it is just showing `^H`. Anyway I can correct that myself? – xpt Jun 22 '20 at 19:15
  • 1
    Note to myself, to reset a broken `screen` TTY, quit screen, do `reset` in tty, then get back into screen again. – xpt May 11 '21 at 15:13