How to kill a process on a port on ubuntu

前端 未结 27 2265
天涯浪人
天涯浪人 2020-12-02 03:05

I am trying to kill a process in the command line for a specific port in ubuntu.

If I run this command I get the port:

sudo lsof -t -i:9001
         


        
27条回答
  •  借酒劲吻你
    2020-12-02 03:59

    Use the command

     netstat -plten |grep java
    

    used grep java as tomcat uses java as their processes.

    It will show the list of processes with port number and process id

    tcp6       0      0 :::8080                 :::*                    LISTEN      
    1000       30070621    16085/java
    

    the number before /java is a process id. Now use kill command to kill the process

    kill -9 16085
    

    -9 implies the process will be killed forcefully.

提交回复
热议问题