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 you can get to a shell prompt (
the first command you should try is probably:
systems with termcap
systems with terminfo
That will try to erase the screen and may also cancel other problems like
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 have a shell prompt and you're on a system using terminfo
Don't use tput init
unless tput reset
doesn't fix things:
If you're using a termcap
system, there's no command quite like
You can simulate them by making an
that 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'
command usually sends resetting or initialization commands
to your terminal.
If every character you type shows up on a different line,
characters don't appear as you type them,
does nothing or prints a
on your screen,
the backspace, interrupt, and kill keys don't work, or lines
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:
stty sane [CTRL-j]
(If your terminal has a [LINEFEED]
key, you can use it instead of
If the system says that those commands don't exist or are an "unknown mode,"
you should make yourself an
shell function (10.9
shell script (44.2
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
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
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):
r: Command not found.
: No previous regular expression
: No current filename
: No lines in the buffer
(It actually doesn't look quite like that, but the first
the editor named e
are all read as commands by
You have to quit e
by typing its
You should make a shell function or alias - or, put a
symbolic link (18.4
shell script in your
lets you run the command from
the previous step (reset
, stty sane
, etc.) by typing a single
(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
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
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:
speed 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
stty icanon echo erase '^?' kill '^u' ...
Note that if you use several different terminals, each may have different
Make yourself several sane
commands; you might
select one automatically as you log in (2.12