Abhay Jain

Dec 22, 2020

2 min read

Kill a Process

If you want to kill a process using the command line, that can be performed by simple steps performed below.

STEP 1: Finding the PID

Command: ps aux | grep “[n]ginx”

In the CMD, we have run a command which displays the process running with its PID (i.e. 12514 and 13262).

ps: Process Status

a: Show processes for all users
u: Display the process’s user/owner
x: Also show processes not attached to a terminal

grep: Globally search for a regular expression and print matching lines

Value in between the “….” is the name of the process you want to find.

Command: sudo lsof -i :8080

In the CMD, we have run a command which displays the process running with its PID (i.e. 12514 and 13262).

sudo(superuser do): Allows programs to be executed as a root user

lsof: list open files

-i: interactive

After which you mention the port number(:8000).

STEP 2: Killing the Process

Command: sudo kill -9 12514

sudo(superuser do): Allows programs to be executed as a root user

kill -9: Terminates the process.

After which you write the PID(a number which shows after the username), which you want to terminate.