How to kill a process on a port on ubuntu

2019-01-12 13:13发布

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

If I run this command I get the port:

sudo lsof -t -i:9001

so...now I want to run:

sudo kill 'sudo lsof -t -i:9001'

I get this error message:

ERROR: garbage process ID "lsof -t -i:9001".
Usage:
  kill pid ...              Send SIGTERM to every process listed.
  kill signal pid ...       Send a signal to every process listed.
  kill -s signal pid ...    Send a signal to every process listed.
  kill -l                   List all signal names.
  kill -L                   List all signal names in a nice table.
  kill -l signal            Convert between signal numbers and names.

I tried sudo kill 'lsof -t -i:9001' as well

标签: ubuntu port kill
19条回答
成全新的幸福
2楼-- · 2019-01-12 13:33

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

 kill $(lsof -t -i:9001)
查看更多
闹够了就滚
3楼-- · 2019-01-12 13:33

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
查看更多
一夜七次
4楼-- · 2019-01-12 13:34

The best way to kill a port in ubuntu terminal is fuser -k 9001/tcp

查看更多
我命由我不由天
5楼-- · 2019-01-12 13:35

you can use

fuser -n tcp -k 9001 

see more details in wikipedia

查看更多
迷人小祖宗
6楼-- · 2019-01-12 13:35

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

查看更多
对你真心纯属浪费
7楼-- · 2019-01-12 13:36

FOR UBUNTU 1- Find what application/process is using the pro, type:

sudo netstat -lpn |grep :8080

and press Enter.

You will get an output similar to this one

tcp6       0      0 :::8080                 :::*                    LISTEN      6782/java

2- I have got the process Id, which is 6782, now this is the process that is using port 8080.

3- Kill the process, type:kill 6782

kill 6782
查看更多
登录 后发表回答