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.

--

--

Developer with 3 yrs of industrial experience in developing scalable web applications.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhay Jain

Developer with 3 yrs of industrial experience in developing scalable web applications.