Sometimes, processes ignore the SIGINT signal sent by Ctrl-C in Bash. For instance, man
and vi
. Assuming you don't want to google or read the manual on how to exit the running process, is there any key sequence that will always work (without leaving the terminal)?
Send the SIGQUIT signal with Ctrl+\.
→ 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:
bg
to resume in the background,fg
to raise to foreground)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:
^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:
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
orkill -9 %1
, etc.Try one of these:
Ctrl+4
Ctrl+\
Or:
Ctrl+Z and then run:
kill %1
Where
%1
is the number of job which was returned when you pressed Control-Z. Add-9
to force the kill.When you're in text console, you could also try: Ctrl-SysRq. The kernel should kill the process.
Or SysRq-k, kill all processes on the current virtual console (can kill X and svgalib programs as well).
See: Magic SysRq key and its command combinations.
It's possible, that you changed the shortcut of copy from:
CTRL+SHIFT+C
To
CTRL+C
That way, when you try to kill a process, the CTRL+C doesn't work.
Try to replace the copy shortcut to CTRL+SHIFT+C.
To quit from man, use
q
To leave vi use:q
Open Terminal → Preferences → Shortcuts and search if by mistake you have replaced any key with Ctrl+C.
Try Ctrl+Alt+Backspace
If you are using ubuntu 10.04 you wanna enable this key to work.
To enable Control-Alt-Backspace
Goto System-->Preferences-->Keyboard
Select the Layouts tab and click on the Layout Options.
Select Key sequence to kill the X server and enable Control + Alt +Backspace.
Note:
Pressing Ctrl-Alt-Backspace will restart your X server.