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)?
Ubuntu – What to do when Ctrl-C won’t kill running job
bashcommand linejob-control
Best Answer
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: