This article is from the Frequently Asked Questions for Linux, the Free/Open Source UNIX-like operating system kernel that runs on many modern computer systems. Maintained by David C. Merrill with numerous contributions by others. (v1.0).
A: You probably sent some binary data to your screen by mistake. Type echo 'c' to fix it. Many Linux distributions have a command, reset, that does this.
If that doesn't help, try a direct screen escape command: echo 'Ctrl-V Ctrl-O '.
This resets the default font of a Linux console. Remember to hold down the Control key and type the letter, instead of, for example, Ctrl, then V. The sequence Ctrl-V Esc C.
causes a full screen reset. If there's data left on the shell command line after typing a binary file, press Ctrl-C a few times to restore the shell command line.
Another possible command is an alias, sane, that can work with generic terminals:
$ alias sane='echo -e " c";tput is2; > stty sane line 1 rows $LINES columns $COLUMNS'
The alias is enclosed with open quotes (backticks), not single quotes. The line break is included here for clarity, and is not required.
Make sure that $LINES and $COLUMNS are defined in the environment with a command similar to this in ~/.cshrc or ~/.bashrc,
$ LINES=25; export $LINES; $COLUMNS=80; export $COLUMNS
using the correct numbers of $LINES and $COLUMNS for the terminal.
Finally, the output of stty -g can be used to create a shell script that will reset the terminal:
1. Save the output of stty -g to a file. In this example, the file is named termset:
$ stty -g >termset
The output of stty -g (the contents of termset) will look something like:
500:5:bd:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:73
2. Edit termset to become a shell script; adding an interpreter and stty
command:
#!/bin/bash stty 500:5:bd:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:73
3. Add executable permissions to termset and use as a shell script:
$ chmod +x termset $ ./termset
[Floyd L. Davidson, Bernhard Gabler]
 
Continue to: