How To Find And Kill Application / Process Running On Particular Port In Linux Systems
Today, I'm going to show you how to find and kill application / process running on particular port in Linux Systems.
We can use lsof
command to find the process running on particular port. The syntax of lsof command to find the application running on particular port looks like following..
lsof -i:port
Summary of above code...
lsof
command is used to list open files.. and the argument -i is used to list files whose ip address / port matched to specified ip address / port.
Note:
If you ignore ip address / port after -i
then the above command will lists processes for all ip addresses...
For example to find the process / application listening on port 80, run the following code..
lsof -i :80
The output will looks like following..
If you omit port value... lsof -i
the output will looks like following one..
Now, we are going to see how to kill the process which is listening on particular port.. If we can find the pid of process we can pipe it to kill command. so that we cann kill the process listening on particular port..
By specifying -t
for lsof
command we can get pid of process listening on particular port... Look at the below command signature..
lsof -t -i :port
If you want to find out pid of process listening on port 80, run the following code..
lsof -t -i :80
The above commands output will looks like..
To kill the process listening on port 80, pass the output of above command to kill command...
sudo kill $(lsof -t -i :80)
That's it for now.. If you like don't forget to share it guys.. You can follow us on fb.com/opensourceinside and also subscribe our channel on Youtube..