cmd查找端口命令
Sometimes when developing multiple applications at once, or trying out demos, I end up with multiple programs running on different ports on my computer: 3000
, 3001
, 1313
, and so on.
有时候,一次开发多个应用程序时,或尝试演示,我结束了在我的电脑上的不同端口上运行多个程序: 3000
, 3001
, 1313
,等等。
If I don’t pay close attention, I might forget which application is running on a specific port.
如果我不密切注意,我可能会忘记哪个应用程序正在特定端口上运行。
How can we determine which program is listening on a port?
我们如何确定哪个程序正在监听端口?
The lsof
command helps us do that!
lsof
命令可以帮助我们做到这一点!
Running
跑步
lsof -i :1313
Will tell me the command that’s currently listening on port 1313:
将告诉我当前正在侦听端口1313的命令:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
hugo 8698 fla 4764u IPv4 0xc72ca30d18e45ef9 0t0 TCP localhost:bmc_patroldb (LISTEN)
In this case it’s the hugo
command, with PID 8698.
在这种情况下,它是带有PID 8698的hugo
命令。
If I want to terminate that program, I can just run kill 8698
.
如果要终止该程序,可以运行kill 8698
。
cmd查找端口命令