Methods to Kill a Course of in Linux

Have you ever ever confronted the state of affairs the place you launched an software and instantly if you are utilizing the applying it turns into unresponsive and unexpectedly crashes? You attempt to begin the applying once more, however nothing occurs as a result of the unique software course of by no means really shut down utterly.

Nicely, it has occurred to all of us in some unspecified time in the future, hasn’t it? The answer is to terminate or kill the applying course of. However how?

Fortunately, there are a number of utilities in Linux that means that you can kill errant processes.

On this tutorial, we’ll present you how you can use kill and killall instructions to terminate a course of in Linux. The primary distinction between these two instruments is that killall terminates operating processes primarily based on title, whereas the kill terminates processes primarily based on Course of ID quantity (PID).

Common customers can kill their very own processes, however not people who belong to different customers, whereas the foundation consumer can kill all processes.

System Kill Alerts

kill and killall can ship a given sign to specified processes or course of teams. When used with out a sign each instruments will ship -15 (-TERM).

Essentially the most generally used indicators are:

  • 1 (-HUP): to restart a course of.
  • 9 (-KILL): to kill a course of.
  • 15 (-TERM): to gracefully cease a course of.

Alerts may be laid out in three other ways:

  • utilizing quantity (e.g., -1)
  • with the “SIG” prefix (e.g., -SIGHUP)
  • with out the “SIG” prefix (e.g., -HUP).

Use the -l choice to listing all obtainable indicators:

The steps outlined under will work on all Linux distributions.

Terminating Processes Utilizing the kill Command

To terminate a course of with the kill command, first you should discover the method PID. You are able to do this utilizing completely different instructions reminiscent of high, ps, pidof and pgrep.

Let’s say our Firefox browser has develop into unresponsive and you should kill the Firefox course of. To search out the method PID use the pidof command:

The command above will print all Firefox processes:

As soon as you recognize the Firefox processes PIDs to terminate all of them sort:

kill -9 2551 2514 1963 1856 1771

Terminating Processes Utilizing the killall Command

The killall command terminates all applications that match a specified title.

Utilizing the identical situation as earlier than, we are able to kill the Firefox course of by typing:

killall accepts a number of choices reminiscent of specifying processes operating as consumer, utilizing common expression and killing processes primarily based on the creation time. You will get an inventory of all choices by typing killall (with none arguments).

For instance if we need to terminate all processes operating as a consumer sara we might run the next command:

Conclusion

Terminating unresponsive applications utilizing the kill and killall instructions is a simple process. You solely have to know the method title or PID.

In case you have suggestions, depart a remark under.

Supply

Germany Devoted Server

Leave a Reply