How to Find and Kill Running Processes in Linux

Efficiently managing running processes is a crucial aspect of Linux system administration, enabling administrators to maintain system performance and troubleshoot issues by finding and terminating processes in a Linux environment.

This article explores the ins and outs of finding and terminating less productive or unwanted processes on your Linux system.

TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.

What is a Process in Linux?

A process on a Linux system can be a running occurrence of an application or program. You can also refer to processes as tasks executing in the operating system.

When a process is running, it keeps on shifting from one state to another and a process can be in one of the following states:

  • Running: meaning the process is either executing or it is just set to be executed.
  • Waiting: meaning that the process is waiting for an event or for a system resource to carry out a task.

There are two types of waiting processes under Linux namely interruptible and uninterruptible.

A waiting process that can be interrupted by signals is called Interruptible, while a waiting process that is directly waiting on hardware conditions and cannot be interrupted under any conditions is called uninterruptible.

  • Stopped: meaning that the process has been stopped, using a signal.
  • Zombie: meaning the process has been stopped abruptly and is dead.

With this brief overview let us now look at ways of finding and killing processes in a Linux system. We’ve already covered a few articles on ways to kill Linux running processes us using kill, pkill, killall, and xkill, you can read them below.

When killing processes, the kill command is used to send a named signal to a named process or group of processes. The default signal is the TERM signal.

Remember that the kill command can be a built-in function in many modern shells or externally located at /bin/kill.

How to Find Process PID in Linux

In Linux, every process on a system has a PID (Process Identification Number) which can be used to kill the process.

You can identify the PID of any process by using the pidof command as follows:

$ pidof firefox
$ pidof chrome
$ pidof gimp-2.8
Find Process PID in Linux
Find Process PID in Linux

How to Kill Processes in Linux

Once you find the process PID, let us now look at how to kill processes. In this first example, I am going to first get the PID of the process and then send a signal to it.

I want to kill the gimp process, so I will do it as follows:

$ pidof gimp-2.8
$ kill 9378

To verify that the process has been killed, run the pidof command and you will not be able to view the PID.

$ pidof gimp-2.8
Kill Linux Process PID
Kill Linux Process PID

You can also send a named signal to the process by using the signal name or numbers as follows:

$ pidof vlc
$ kill -SIGTERM 9541
$ pidof vlc
Kill Linux Process PID by Signal
Kill Process PID by Signal

Using the signal number to kill a process:

$ pidof banshee
$ kill -9 9647
$ pidof banshee
Kill Linux Process PID by Number
Kill Process PID by Number

In the above example, the number 9 is the signal number for the SIGKILL signal.

How to Kill Multiple Process PIDs in Linux

To kill more than one process, pass the PID(s) to the kill command as follows:

$ pidof gimp-2.8
$ pidof vlc
$ pidof banshee
$ kill -9 9734 9747 9762
Kill Multiple Linux Process PID's
Kill Multiple Linux Process PIDs
Summary

There are many other ways of killing processes in Linux, these few examples just help to give you an overview of killing processes.

Do let us know how you kill processes in Linux. and also tell other ways if any via comments.

If this article helped, with someone on your team.

TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
☕ Buy Me a Coffee
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

11 Comments

Leave a Reply
  1. pidof requires knowing the exact name of the process, I have always used this command:

    ps ax | grep gimp
    

    instead pidof gimp would not have been useful.

    Reply
  2. Hi! :-)

    “killall” is a better options than “kill” at my opinion.
    Also a usefull diagnose tool if a program crashes, is the “htop”.
    In case of such a problem, I’m switching to another virtual console (eg. with Ctrl-Alt-F1) and I’m giving “htop” (after logging in), in order to find out wich process is the problematic one.
    After that I can kill it from inside “htop”, or exit from it and use “killall”.

    Just my 2 cents.

    Bye! :-)
    G.

    Reply
    • pkill is even better. With killall you might select more process than what you want, pkill allow you to select more precisely :)

      Reply
    • Getting the right utility to use is very important for a given situation when killing processes. It is good to know when to use kill, killall, pkill and pgrep.

      Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Something went wrong. Please try again.
Check your email for a magic link to get started.