« Back to Processes: Frequently Asked Questions

How to kill a running process by its name

How to kill a running process by its name?

Use the pkill command to select a running process by its name and send a kill signal.

pkill --interactive PROCESSNAME

To find running processes by their name and stop it, use the killall or pkill command.

Examples using killall

The killall command has the --interactive option that will ask a confirmation before stopping processes.

# killall -i nginx
Kill nginx(51055) ? (y/N) n
Kill nginx(60297) ? (y/N) n
Kill nginx(60298) ? (y/N) n
nginx: no process found

As we answered ’n’ to all questions, killall won’t stop any running processes.

Examples using pkill

pkill nginx

When using pkill, there is no interactive confirmation. Use the pgrep command with the -l option to confirm the right processes are targeted.

Relevant FAQ: How to show a running process name and its process ID (PID)?

Process signals

Most of the tools that can send a signal to a process or a group of processes, can be instructed to send a specific process signal. This might be useful when a process is stuck and does not respond to the default SIGTERM signal.

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 a cheat sheet available.

  • killall
  • pkill

Other questions related to Processes

    Related articles

    Like to learn more? Here is a list of articles within the same category or having similar tags.

    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