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'

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

解决方案

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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值