我试图在命令行中为ubuntu中的特定端口终止进程。

如果我运行此命令,我将获得端口:

sudo lsof -t -i:9001

所以…现在我想跑:

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

我收到以下错误消息:

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.

我也尝试过杀“lsof-t-I:9001”


当前回答

其流程分为两个步骤:

知道端口号8080上的进程id(可以是任何)id 8689的终止进程(可以不同)热熔器-n tcp 8080#o/p 8080/tcp 8689杀死-9 8689

其他回答

要终止在端口号9001上运行的进程

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


lsof   - list of files(Also used for to list related processes)

-t     - show only process ID

-i     - show only internet connections related process

:9001  - show only processes in this port number

kill   - command to kill the process

-9     - forcefully

sudo   - command to ask admin privilege(user id and password).

有关更多信息,请访问我的博客

xargs是一个非常有用的命令。

您可以使用这样的管道命令

lsof -t -i :9001 | xargs sudo kill

它的作用:它接受第一个命令的输出,在本例中是在端口上运行的进程,并将其传递给sudokill。

您可以在终端中使用以下命令热熔器-k 3000/tcp

使用killport命令:

sh killport 9001 

要下载shell,可以使用wget:

wget https://cdn.rawgit.com/abdennour/miscs.sh/e0aac343/killport

只需在终端中输入以下命令

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