« Back to Processes

Kill a process that won't respond to CTRL+C

Sometimes a process gets stuck and how often you try, it won’t respond to the combination of CTRL+C. One option is to open a second shell, then perform a kill.

kill 1234

Pushing a job to the background

While this works, there is usually a much easier way. This involves pushing a running process into the background by pressing CTRL+Z.

[1]+  Stopped                 ./runserver

Kill the process

To get it back to the foreground, we would normally run fg. Instead, we tell it to stop.

kill %1

The %1 refers to the first process that is in the background, noted by the [1] in the output above. After running the kill command, we see the following output:

[1]+  Stopped                 ./runserver

It is typically showing the same output, but this time the process received a kill signal. When you put multiple processes to the background, it would make sense to first check the output of the jobs command. It will show any job that is running, including those that are pushed to the background and no longer visible on screen.

Jobs optionExplanation
-lShow process ID (PID)
-nOnly show those processes that have a changed status since last run of jobs
-pShow PID only
-rOnly show running jobs
-sOnly show stopped jobs

Do you have another great tip to deal with processes? Let it know!

Relevant commands in this article

Like to learn more about the commands that were used in this article? Have a look, for some there is also cheat sheet available.

  • fg
  • jobs
  • kill

Feedback

Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution.

Mastodon icon