This page describes how to get out of problems when programs go wrong. The most common way is by killing the process - an individual program or one of its parts. If you kill a process, you'll probably lose any unsaved data in that program, and possibly from other programs it has spawned or is communicating with..
This page also describes what to do if the computer is completely frozen.
These suggestions have more adverse consequences the further down the list you go. For example killing a window in KDE will lose the unsaved data in that program, whereas pressing the reset button could corrupt all data on a hard drive (in extreme cases). Don't resort to extreme measures unless you have no other choice.
On the Desktop
In X-Window (general)
The default easy-to-use application for killing frozen pieces of software when using an X environment is xkill. When executed, the mouse cursor will change to an icon of a skull and crossbones, and the next window you click will be killed.
Sometimes this can be done by doing Control+Alt+Escape, or alternatively by bringing up the "Run" dialog box with ALT+F2 and typing in "xkill" followed by RETURN.
KDE System Guard (installed by default) can be used to kill troublesome processes. Ctrl+Esc is the default key combination for starting it, or run ksysguard.
The gnome-system-monitor GUI program is one way to view active processes, end processes, and kill them too. There is also a "Force Quit" widget which can be added to a panel which replicates the function of xkill.
Killing at the Console
The easiest way of stopping a program running on the terminal you are using is pressing Ctrl+C, which asks a program to stop (sends SIGINT) - but the program can ignore this. Ctrl+C also works on programs like XTerm or Konsole. See also Alt+SysRq+K below.
In addition, there are several commands to kill processes from any terminal window, not just the one a program is running from. You can use a program like XTerm or Konsole to provide a fake terminal, or you can switch to a terminal by pressing ctrl+alt+function key; ie Ctrl+Alt+F2 to Ctrl+Alt+F6 (depending on your system). Ctrl+Alt+F7 gets you back to the desktop (again, depending on your system).
The Guide to UNIX/Commands/Process Management page has more information on process management commands, but a few popular ones are below:
- pkill and killall are the most useful program-killing commands, and they do similar things. Just type
pkill -TERM program_name
- In addition, pgrep can be used to list running processes.
Forcing the X Window System to Quit
- To kill and restart the X Window System, press Ctrl+Alt+Backspace. Lots of programs need X-Window, so using this will cause most running programs to quit or crash.
- You should probably try to reset your computer after this: type
shutdown -r now
- to do this. You may need to be root.
- If you have access to the command line, you can also type
sudo /etc/init.d/(gdm or kdm or xdm) shutdown
- to stop X.
- Note that the ability to restart X by pressing Ctrl+Alt+Backspace can be disabled from X's configuration file. In the X.Org implementation, a "DontZap" option can be added to xorg.conf to do this. If Ctrl+Alt+Backspace is not working, this may be the reason why.
If you do Ctrl+Alt+Backspace and you have a login manager like XDM enabled usually you will be thrown back to that after x RESTARTS. If you started X by typing startx this will usually throw you back to the command line
Ctrl+Alt+Backspace is useful for restarting X after changing the resolution, for example, too.
If all else fails, you may still be able to communicate with the Kernel.
To use, just press the Alt and SysRq (PrintScreen) keys and one of the keys listed below, all together. You should try switch into a terminal window, if possible, first by pressing Ctrl+Alt+F2 (use Ctrl+Alt+F7 to return to the desktop).
If your computer is not responding you can use the following steps to perform a reboot with less chance of fscking your files. This is a suggested method:
- Press Ctrl+Alt+F2 to switch to a terminal window. Sometimes, this is not possible.
- Press Alt+SysRq+R to get the keyboard
- If pressing Ctrl+Alt+F2 before failed, try it again now.
- Press Alt+SysRq+E to term all processes.
- Press Alt+SysRq+I to kill all processes.
- Press Alt+SysRq+S to sync your disks.
- Wait for OK or Done message. If you don't see a message, look at your HDD light to see if Sync made a difference.
- Press Alt+SysRq+U to umount all disk drives.
- Wait for OK or Done message. If you don't see a message, in 15-30 seconds, assume disks are unmounted (or that an unmount is not posssible) and proceed.
- Press Alt+SysRq+B to reboot.
The Letters used spell REISUB - use the mnemonic Reboot Even If System Utterly Broken. Another popular one is Raising Elephants Is So Utterly Boring, or just spell BUSIER backwards.
The Full list of available commands is shown below. It's largely taken from Documentation/sysrq.txt in the Linux Kernel Sources.
|R||UnRaw||Turns off keyboard raw mode. This allows input from the keyboard even if X-Window has crashed.|
|K||SAK - Kill all on console||Secure Access Key - Kills all programs on the current virtual console. This is useful if you want to make sure there are no programs waiting on the console to grab your password, or if a process won't let you switch consoles.|
|S||Sync||Attempts to sync all filesystems. This lessens the chance of data loss and fscking. Syncing is complete when "done" or "OK" is printed.|
|U||Umount||Attempts to remount all filesystems as read-only. Umounting is complete when "done" or "OK" is printed.|
|B||Reboot||Will immediately reboot without syncing or unmounting any disks. Before using this use Alt+SysRq+S and Alt+SysRq+U to avoid data loss.|
|C||Crashdump||Will perform a kexec reboot, in order to take a crashdump. Before using this use Alt+SysRq+S and Alt+SysRq+U to avoid data loss.|
|O||Power Off||Turns off the computer without syncing or unmounting disks. Before using this use Alt+SysRq+S and Alt+SysRq+U to avoid data loss.|
|P||Show Pc||Attempts to dump all registers and pointers to console.|
|T||Show Tasks||Attempts to dump a list of all tasks to console.|
|M||Show Memory Info||Displays memory info to console|
|V||Voyager processor info||Dumps Voyager SMP processor info to your console.|
|0-8||Kernеl Error Verbosity||Set the console log level for kernel messages. Setting to 0 only shows messages like PANIC and OOPS|
|F||OOM Kill||Calls oom_kill to kill a memory hog process|
|E||Term||Sends SIGTERM signal to all processes.|
|I||Kill||Kills (sends SIGKILL signal to) all processes.|
|L||Kill + Kill Init||Kills (sends SIGKILL signal to) all processes, including init. You will not be able to do anything else after using this!|
|N||Nice||Make real-time processes nice-able.|
|H||Help||Prints some help|
Certain systems (systems administrated by a department or group other than yourself, e.g. a corporate or government location) may remove the ability to use the SysRq key combinations in order to secure their system from low level commands. If you try a few commands and notice nothing is happening, or error messages occur, this may be the case.
The Big Red Button
The final option is, of course, the power button on your computer's physical exterior. Modern PCs have ACPI buttons, which just send the shutdown request to the kernel. If the ACPI daemon is listening and correctly configured, it can signal
init and perform a clean shutdown.
If ACPI doesn't work, you will need to cut off electrical power. This is done through a "hard switch" (generally labeled "reset"), possibly using the same button as before but holding it pressed for 5 or so seconds. Taking out the battery (on laptops) and physically disconnecting all power cables is, of course, the only method guaranteed to work. (Make sure no other method listed above works. Even as a last resort, unplugging your computer while it is running is still not recommended.)
Resetting without shutting down can cause problems with the file system. To try and fix this problem, fsck will be run when you next boot up, and journaling filesystems will attempt to complete or rollback files which were changing.