What to do when Ctrl-C won't kill running job?

Send the SIGQUIT signal with Ctrl+\.

.. $ sleep 10
^\Quit

→ This is equivalent to kill -3 pid. Programs run in user-space don't ignore sigquit.

There is also a set of Magic SysRq keyboard shortcuts. One of the more interesting ones is this: Alt+SysRq+k. It kills every process on the current virtual console. If one of your ttys is completely and utterly broken, this can be used to go back. On the tty running X.org, it can be used to kill X without mercy.

The SysRq key is, on most keyboards, the same as the Print Key. On my notebook, it can be invoked using the Fn key; I.e. Alt→Fn→Print→k in that order.

Here are some of the basic process management shortcuts:

  • Ctrl+Z: pause a process (plus bg to resume in the background, fg to raise to foreground)
  • Ctrl+C: politely ask the process to shut down now
  • Ctrl+\: mercilessly kill the process that is currently in the foreground
  • Alt+SysRq+s: Write data to disk (always do this before killing anything important)
  • Alt+SysRq+s, k: mercilessly kill all current processes on a given virtual console
  • Alt+SysRq+s, b: mercilessly reboot without unmounting,
  • Alt+SysRq+r, e, i, s, u, b: Safely reboot even if the system is utterly broken,

Note: Ctrl+Z, in contrast to Ctrl+C and Ctrl+\, also works for man, vi, less, and the like.

When in doubt, the follwing procedure will almost always work:

~$ sleep 10
^Z
[5]+  Stopped              sleep 10
~$ ps
  PID TTY          TIME CMD
 4804 pts/0    00:00:00 bash
 6207 pts/0    00:00:00 sleep
 6208 pts/0    00:00:00 ps
~$ kill -9 6207
[5]+  Killed                  sleep 10
~$ 

^Z of course indicates that Ctrl+Z has been pressed.


For a more in-depth look at Shells and Terminals, also see my answers on:

  • What are shells?
  • Why is a virtual terminal "virtual", and what/why/where is the "real" terminal?

You can try Ctrl+\


Sometimes the CTRL+C is getting sent to the wrong program or input channel. This is especially common with editors such as vi, with commands with piped output, complex bash commands involving loops, etc.

A simple, quick solution is to suspend the job CTRL+Z and then kill it by job number: kill %1 or kill -9 %1, etc.