码迷,mamicode.com
首页 > 系统相关 > 详细

Linux下通过端口号查询占用的进程,并知道其所在的位置

时间:2017-12-15 00:47:37      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:lis   lib   3.4   jline   gpo   端口号   post   inf   roo   

比如要查询2181端口。

1、查询端口占用的进程ID

netstat -anp | grep 2181
tcp6       0      0 :::2181                 :::*                    LISTEN      10997/java 

2181为端口号

10997为PID

还可以使用:

lsof -i:2181
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    10997  jim   25u  IPv6 197822      0t0  TCP *:2181 (LISTEN)

2、根据PID查询所在进程位置

ps -ef | grep 10997
jim      10997  1959  0 12月14 pts/2  00:00:00 /usr/lib/jvm/java-8-oracle/bin/java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /home/jim/opt/zookeeper-3.4.9/bin/../build/classes:/home/jim/opt/zookeeper-3.4.9/bin/../build/lib/*.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/home/jim/opt/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/home/jim/opt/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/home/jim/opt/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/home/jim/opt/zookeeper-3.4.9/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /home/jim/opt/zookeeper-3.4.9/bin/../conf/zoo.cfg

 

参考:

http://blog.csdn.net/rocklee/article/details/50886739

http://blog.csdn.net/zhongweijian/article/details/7942611

 

Linux下通过端口号查询占用的进程,并知道其所在的位置

标签:lis   lib   3.4   jline   gpo   端口号   post   inf   roo   

原文地址:http://www.cnblogs.com/EasonJim/p/8040686.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!