How to kill a process in Linux


Getty Illustrations or photos/iStockphoto

Each software and company on your Linux machine runs as a process. And, for the most aspect, those procedures operate quite efficiently. Every so normally, nonetheless, you may discover a approach (an application or a support) that goes astray and both slows down your technique or results in other problems (such as a locked-up desktop). 

When that transpires, you will need to be ready to eliminate people runaway procedures. Now, most Linux desktop environments contain a GUI resource that helps make killing a approach a basic issue of deciding upon the system and then selecting Get rid of (Figure 1).

The Pop!_OS System Monitoring tool

Figure 1: Killing a method from inside the Pop!_OS desktop GUI.

Picture: Jack Wallen

That’s all fantastic and excellent, but what takes place when you cannot accessibility the GUI mainly because a runaway system is gobbling up your system memory)? Which is when you convert to the command line. 

I’m likely to show you two straightforward approaches to eliminate a Linux system from the command line. You’ll be astonished at how simple it really is.

How to use the kill command

The to start with process I will demonstrate you utilizes the get rid of command. The eliminate command kills procedures by way of their PID (course of action ID). A normal get rid of command seems like this:

The place PID is the process ID for the process in problem. 

You’re possibly asking by yourself, “The place do I find the PID?” Excellent dilemma. Here’s how. Let’s say the difficulty software is the Firefox world wide web browser. To destroy Firefox with the eliminate command, open up a terminal window and locate the PID with:

ps aux |grep firefox

The breakdown of the higher than command is simple:

  • ps: reports a snapshot of the at present running procedures.
  • aux: lifts the BSD-design and style “only your self” restriction as nicely as the BSD-design “should have a tty” restriction and lists all processes in the person list.
  • |: pipe the output of ps to the future command (in this circumstance, grep)
  • grep: match only the course of action with the sting that follows.
  • firefox: the approach we’re searching for.

Of class, in the case of Firefox, you may see a system for each single tab you have open up. To really destroy Firefox, you require to track down the PID of the extremely initially outlined. That listing will glimpse a thing like this:

jack       21960  7.6  2.5 14450944 825944 ?     SNl  Jun12 122:44 firefox

The PID is the first quantity (right to the right of the username). So, for the earlier mentioned case in point, the destroy command would be:

The higher than command need to kill Firefox.

How to use the killall command

This method is noticeably easier. As an alternative of applying the PID of the system, you use the title of the course of action. So, if we want to get rid of the process named firefox, the command would be:

If you want to be secure, you can drive killall to validate that you want to get rid of the command making use of the interactive selection like so:

Answer y to the concern, and the Firefox approach will be killed. 

Think it or not, which is how quick it is to kill a runaway procedure (or any procedure, for that matter) on Linux. Certainly, there are extra choices obtainable for each of all those instructions, but what I’ve outlined higher than will get you began. To study much more about each individual command, examine the man internet pages with person destroy and guy killall.

Sharing is caring!

Facebook Comments

Leave a Reply