Gremlins (like line noise on a modem, a bug in a program, a really long line of output, non-printable characters in a file you cat to your screen, etc.) can sneak into your system somewhere and mess up your terminal screen or window. The screen could have a bunch of flashing junk, the character set could turn into hieroglyphics, words could start coming out underlined or in inverse video, the line could lock up... well, there are lots of possibilities.
Here's a rough list of things to try. This might be worth reading through right now. Some things in here need to be ready before your terminal locks up.
If running clear doesn't clear up your screen completely and your terminal has a setup menu, look for a "clear screen" function and try it. (If you don't know how your terminal's setup mode works, find the manual or find an expert. Write down the steps and keep them close to your terminal.)
If you're using a termcap system, there's no command quite like those two. You can simulate them by making anthat runs the command from your login setup files. (Why not do it now, for the next time you get into this mess?) Here's a simple alias:
alias newterm 'set noglob; eval `tset -srQ \!*`; unset noglob'
If every character you type shows up on a different line,
characters don't appear as you type them,
does nothing or prints a
^M on your screen,
the backspace, interrupt, and kill keys don't work, or lines
jump down the screen like this
you've probably got trouble with the settings of your port (UNIX terminal device). One of the following commands can make your terminal usable. It might not be set up the way you're used to, but at least you'll be able to log out and log in again:
[CTRL-j] reset [CTRL-j]%
[CTRL-j] stty sane [CTRL-j]
If the system says that those commands don't exist or are an "unknown mode," you should make yourself an, , or that executes an stty command similar to the one below. The exact parameters you use will depend on your normal UNIX setup:
stty echo -nl -cbreak
Call it something like sane. You may need to execute it by typing LINEFEED or CTRL-j before and after.
If that doesn't work perfectly, here's what to do. The next time you log in and your screen works just right, typing stty everything or stty -g (see below) should help you decide exactly what parameters to use in your sane command.
If the system seems to treat every character you type as a separate command (and you may not be able to see the characters you type):
resetr: Command not found. : No previous regular expression : No current filename : No lines in the buffer
You should make a shell function or alias - or, put a
] (right square bracket) as the name of mine.
To make mine, I made a symlink in my bin:
ln -s /usr/ucb/reset ]
(Your system's reset command may have a different pathname.)
Now, to fix a goofed-up terminal, I just type a
] at a shell prompt
(it may need a
before and after).
Best of all, if your system has the command stty -g, you can use it to save your favorite terminal settings in a file. Then, when your terminal is goofed up, read those settings in again from the file. Here's how. First, when your terminal is working just the way you want it, type:
stty -g >$HOME/.stty
Then make your alias, shell script, or shell function named sane,
], etc. (previously explained) that runs the command:
stty `cat $HOME/.stty`
This should restore your terminal the way it was when you first ran the stty -g command.
If your system doesn't have stty -g, you can fake it. Run the command stty everything or stty -a and look at the settings:
stty everythingspeed 38400 baud, 0 rows, 0 columns parenb -parodd cs7 -cstopb -hupcl cread -clocal -crtscts -ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr icrnl -iuclc ixon -ixany -ixoff imaxbel isig iexten icanon -xcase echo echoe echok -echonl -noflsh -tostop echoctl -echoprt echoke opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tabs erase kill werase rprnt flush lnext susp intr quit stop eof ^? ^U ^W ^R ^O ^V ^Z/^Y ^C ^\ ^S/^Q ^D
Then check your stty manual page and read about those settings
(some of them, like the parity settings, might not be appropriate for all
your login sessions).
Put the settings in your sane or
stty icanon echo erase '^?' kill '^u' ...
Note that if you use several different terminals, each may have different settings. Make yourself several sane commands; you might.
If worse comes to worst, try the steps from article 42.2. Find another place to log in to your account. Run ps to find your processes on the hung-up terminal or window and kill them. Then turn off the terminal or close the window and log in again. (If you didn't have a way to kill the processes before you logged in again, be sure to kill your old processes right away after you log in.)