How to kill a process on a port on ubuntu

前端 未结 27 2229
天涯浪人
天涯浪人 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:53

    kill -9 $(lsof -t -i:9001)

    can be used to kill the process. You can use any port number instead of 9001

    0 讨论(0)
  • 2020-12-02 03:54

    To kill on port service in ubuntu, Enter the below command in terminal

    In Terminal :

    sudo fuser -k port/tcp
    sudo fuser -k 8001/tcp
    
    0 讨论(0)
  • 2020-12-02 03:55

    Kill PORT:

    sudo is important to show process id.

    $ sudo netstat -antlp | grep 45136
    tcp      0      0 0.0.0.0:45136         0.0.0.0:*        LISTEN           **-** 
    
    $ kill -9 45136
    
    0 讨论(0)
  • 2020-12-02 03:55

    sudo kill $(sudo lsof -t -i:1337)

    0 讨论(0)
  • 2020-12-02 03:57

    You want to use backtick not regular tick:

    sudo kill -9 `sudo lsof -t -i:9001`
    

    If that doesn't work you could also use $() for command interpolation:

    sudo kill -9 $(sudo lsof -t -i:9001)
    
    0 讨论(0)
  • 2020-12-02 03:57

    Use this for killing process which is running on port number "9001"

     kill $(lsof -t -i:9001)
    
    0 讨论(0)
提交回复
热议问题