Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In an interactive console like irb, sometimes something will go wrong and the console becomes unresponsive. One solution is to suspend the process, then kill it.

To suspend the process, I can press Control+Z. To kill that process, I can run ps -ef | grep 'irb' to list all the processes and show only the ones that contain 'irb', then get the process ID from that list and type kill [insert PID here].

That's a hassle. I know that there's a way to just suspend the process, then type kill [some symbol here], with the symbol representing "the last process that was suspended."

What's the command-line symbol for "the PID of the last suspended process"?

share|improve this question
up vote 9 down vote accepted

You might be looking for the $! variable (bash manual, section Special Parameters).

However, you don't need the PID – the built-in kill command also accepts job identifiers, such as %2, which are shown when you press Ctrl-Z or type jobs. You can use %, %+ or %% to refer to the latest job. (Other possibilities are in bash manual, section Job Control.)

[4]+  Stopped                 python
$ kill %4
share|improve this answer
I think kill % was what I was looking for. Though I suppose this is actually the last job started rather than the last one suspended, for me this is typically the same one. – Nathan Long Oct 13 '11 at 20:18
@NathanLong: No, % is the last suspended job. – grawity Oct 13 '11 at 20:48
awesome, thanks for the clarification. :) – Nathan Long Oct 14 '11 at 12:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.