If you connect to a remote Linux server via SSH and suddenly find that your terminal is acting strangely—perhaps the backspace key generates weird characters (like ^H), the screen output is jumbled, or the line wrapping is completely broken—it usually means your terminal emulator’s session settings have become corrupted or desynchronized from the host system. Before you forcefully disconnect and log back in, you can attempt to rescue the session using the tset command.
What is the tset Command?
The tset (Terminal Set) command is a legacy UNIX utility designed specifically to initialize, reset, and configure terminal settings based on the TERM environment variable. When executed, it sends a specific sequence of control characters to the display to clear garbled states, reset tab stops, fix line-ending behaviors, and re-establish the correct erase and kill characters for your keyboard.
How to Reset a Corrupted Terminal
If your terminal is actively misbehaving, simply type the command and press Enter:
tset
Depending on how badly the terminal state is corrupted, you might not even be able to see the letters as you type them. Just trust your fingers, type the four letters, and press Enter. The screen will usually flash or blank out for a split second as the settings are re-applied, and your command prompt should return to normal.
Forcing a Specific Terminal Type
Sometimes, the issue is that the remote server does not recognize the modern terminal emulator you are using (like xterm-256color), causing formatting issues. You can use tset to force the session to downgrade to a universally recognized, generic terminal type like vt100 or basic xterm.
tset -T vt100
The -T flag specifies the exact terminal type you want to emulate. This is incredibly useful when dealing with very old, legacy UNIX systems or bare-metal serial console connections that do not support modern color codes or advanced window resizing events.
Note: While tset is powerful for initialization, if your terminal is completely locked up and ignoring all keyboard input, you might need to use the simpler reset command (which is actually just a symlink that calls tset with specific hard-reset flags).