During your Unix session, your terminal may not respond when you type a command, or the display on your screen may stop at an unusual place. That’s called a “hung” or “frozen” terminal or session. Note that most of the techniques in this section apply to a terminal window, but not to non-terminal windows such as a web browser.
A session can hang for several reasons. For instance, your computer can get too busy; the Terminal application has to wait its turn. In that case, your session starts by itself after a few moments. You should not try to “un-hang” the session by entering extra commands, because those commands will all take effect after Terminal comes back to life.
Tip
If your display becomes garbled, press Control-L. In the shell, this will clear the screen and display the prompt. In a full-screen program, such as a text editor, it will redraw the screen.
If the system doesn’t respond for quite a while (how long that is depends on your individual situation; ask other users about their experiences), the following solutions usually work. Try the following steps in the order shown until the system responds:
- Press the Return key once.
You may have typed text at a prompt (for example, a command line at a shell prompt) but haven’t yet pressed Return to say that you’re done typing and your text should be interpreted.
- Try job control (see Chapter 9); type Control-Z.
This control key sequence suspends a program that may be running and gives you a shell prompt. Now you can enter the
jobs
command to find the program’s name, then restart the program withfg
or terminate it withkill
.-
Press Control-C or -
.
. This interrupts a program that may be running. (Unless the program is run in the background; as described in Section 9.1, the shell waits for a background program to finish before giving a new prompt. A long-running background program may thus appear to hang the terminal.) If this doesn’t work the first time, try it once more; doing it more than twice usually won’t help.
- Type Control-Q.
If output has been stopped with Control-S, this will restart it. (Note that some systems will automatically issue Control-S if they need to pause output; this character may not have been typed from the keyboard.)
- Type Control-D once at the beginning of a new line.
Some programs (such as
mail
) expect text from the user. A program may be waiting for an end-of-input character from you to tell it that you’ve finished entering text. Typing Control-D may cause you to log out, so you should try this only as a last resort.
Otherwise, close your Terminal window and open a new one.
Get Learning Unix for Mac OS X, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.