Killing Linux Processes With killall Command

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/killing-linux-processes-killall-command/
PINTEREST
PINTEREST
INSTAGRAM

We have previously looked the command kill to kill process accordin to their names, owners etc. But using only kill command to kill a proccess according to its owner is done with supportive commands like grep. In this tutorial we will look more compact and all in one command killall .

Syntax

The syntax of the killall command is like below.

Syntax

Syntax

Help

Simple and fast help information about the command can be listed like below. As we see below killall command provides features like exact process name match, ignoring case, interactive usage, verbose or debug mode operation.

Help

List Process With ps

As killall provides convenient ways to kill process with its name listing process and using complete process names will make killall operations more reliable. We will list all process in the system where user related process will generally listed in the below of the output.

List Process With ps

List Process With ps

Kill Process

Now we can start kill processes according their name. This example is a simple example where we only provide some term which is resides in the process name. Our process is watch ls like below.

Now we can provide the term watch to the killall command like below. And after that command we can the process and see that is killed.

LEARN MORE  How To List Shutdown Events In Linux?

Kill Process

Kill Process

Kill With Exact Process Name

In previous example we have only provided some part of the process name not the whole. In some situations this can not be suitable because of similar named processes. We can specify exact name to exactly specify the process. In this example we have two process with similar name as we can see below.

Now we only want to kill process watch ls which PID is 3733 . But we do not want to kill watchgnupg which PID is 3732 .

Now we will provide process name with the -e parameter too match exact name of the process like below.

We check again the running processes and see only watchgnupg process.

Ignore Case

While killing processes the name of the processes is important. The processes name can be upper case or lowercase which is not deterministic. In this situations using ignore case parameter is important. -I parameter can be provided to ignore case like below. In the example below we can see that there is instance of watch . We will kill by providing uppercase WATCH term like below.

Ignore Case

Ignore Case

Kill According To Process User Name

As we know every Linux process have a owner user name. Killall command supports killing processes according to their user names. Keep in mind that this will kill all processes of the specified user. In this examples we want to kill user name ismail processes.

LEARN MORE  What is Penetration Test? What Are Penetration Test Phases?

As we see we have killed also our ssh session which user name was ismail too.

Kill According To Process Group Name

As we know every Linux process have a owner  group name. And this feature is same as killing according to user name. We only provide the group name of the processes with the -g option like below.

Get Confirmation Before Killing Processes

Up to now we have killed processes harshly without warning of a confirmation. There is an option to ask about confirmation while killing processes like below. The option is -i . This options is defined also interactively because of its usage way. While killing process also the PID is provided for stability.

Get Confirmation Before Killing Processes

Get Confirmation Before Killing Processes

Kill Processes According to Running Time

There is another interesting feature of the killall command. Processes can be killed according to their run time. In this example we will kill all processes that runs more than 1 minutes. This options is -o

Also we can kill processes less than specified time. This is feature is expressed as -y option.

We can below how the time is expressed for this feature.

  • s  seconds
  • m minutes
  • h hours
  • d days
  • w weeks
  • M months
  • y years

Using Regular Expression

Up to now we have used specific processes names. This is simple to express but there are times where we need to expresses generic processes names those are similar but not the same. Regular expressions is the way to express structural parts in the text. In this example we will kill all procceses those starts with w and ends with h .

LEARN MORE  limits.conf File To Limit Users, Process In Linux With Examples

In this example only the watch processes is killed because we have restricted regular expression that the end of the processes name must be h . So only watch processes is matched and killed.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/killing-linux-processes-killall-command/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)