How to find and kill a Process Listening on a port in Linux? netstat and lsof command examples

In Linux, many times, you want to find out the PID of a process that is listening on a port e.g. if multiple tomcat servers are running on a host and you have to kill that process, but in order to kill that process you need the process id, how do you find the PID of the tomcat listening on port 8080? There are many Linux commands to find the process using a specific port, but I'll share what I use. I always use the netstat command with -p option, which displays the process id of the process listening on a port. Btw, netstat is not the only command to find all processes using a particular port, you can also use the lsof command for the same purpose.

تعليقات

المشاركات الشائعة من هذه المدونة

Why use Underscore in Numbers from Java? Underscore in Numeric Literals Example

3 ways to convert String to Boolean in Java? Examples

Coursera's TensorFlow: Advanced Techniques Specialization Review [2022]