Killing a job in Ubuntu

This is probably a frequently asked question, but I've been unable to find good documentation.

I have jobs running on my system:

foo@fooBox:~/tmp$ jobs
[1]+  Stopped                 foo bar baz

How can I kill this process? I've tried various commands, like kill 1, but it hasn't worked.


Solution 1:

You can use the method suggested by @fideli, or you can use the kill command like so:

kill %1

This will kill the first suspended command. You can also find a list of suspended commands like so:

jobs

and it will provide output like such:

[1]+  Stopped                 yes

If you have multiple stopped jobs, the number in brackets ([1]) will be the job number, the one you provide after the % in the kill command.

Solution 2:

If you run ps ax you will get a list of all processes running. Look for the one you want to kill and note the number in the PID column. E.g. say the number was 10203, you would then run:

kill 10203

You can also run ps ax | grep foo to find the exact program you're looking for. Finally, you could run:

killall foo

to kill all instances of foo.