本文介绍了如何在Ubuntu上的端口上杀死进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在命令行中终止ubuntu中特定端口的进程.
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
所以...现在我要运行:
so...now I want to run:
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.
我也尝试过sudo kill 'lsof -t -i:9001'
推荐答案
您想使用反引号而不是常规的勾号:
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)
这篇关于如何在Ubuntu上的端口上杀死进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!