如何杀死 ubuntu 端口上的进程 [英] How to kill a process on a port on ubuntu
本文介绍了如何杀死 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 端口上的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文