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
Case 1: Terminate the process of a particular program
In the CMD, we have run a command which displays the process running with its PID (i.e. 12514 and 13262).
Decoding the command:
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.
Case 2: Clear a particular port
In the CMD, we have run a command which displays the process running with its PID (i.e. 12514 and 13262).
Decoding the command:
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
Decoding the command:
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.