How to stop an application or process from the CLI

How to stop an application or process from the CLI

Using the command line interface (CLI), a user can stop (or kill) an application or process. This can be done on Linux or Windows.

Tags: command line Linux

Requirements

Access to the Linux or Windows command line interface.

Procedure

Linux:

First, you will need to know the process ID. Running processes can be listed using the following command:

ps -A

Once you have obtained the process ID, you can request for the application or process to end by:

kill ####

where “####” is the process ID. If you want to force the process to end, you can use:

kill -9 ####

where “####” again is the process ID. You can use ps again to see if the process has terminated.

Windows:

Use:

tasklist | findstr processName

to find the process ID of the process you are trying to terminate. “processName” in the above command should be replaced by the name or part of the name of the process you are looking for. If you want a list of all processes, simply use:

tasklist

without redirecting the output to the findstr command. A sample command with sample output is:

C:\Users\User>tasklist | findstr iexplore
 iexplore.exe 4632 Console 1 28,112 K
 iexplore.exe 4676 Console 1 92,356 K

Then, once you have obtained the process ID, you can terminate it with:

taskkill /pid ####

where “####” is the process ID of the application or process you wish to end.

More Information

Linux:

Type either:

man ps
man kill

Windows:

Type either:

tasklist /?
taskkill /?

for more information.