一、首先根據名稱用ps命令查看進程ID:java
ps -ef | grep zookeeper
jim 10997 1959 0 12月14 pts/2 00:00:01 /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
10997爲進程IDapache
後面是啓動路徑和對應的進程名api
1.一、對於在Java虛擬機中運行的進程,好比tomcat的守護進程,能夠直接用jsp命令查看:tomcat
jps -l | grep zookeeper
10997 org.apache.zookeeper.server.quorum.QuorumPeerMain
已經知道進程的確切名稱,能夠用pidof查看: oracle
pidof Name
不過這個通常少用,由於真的很難查 jvm
二、查到進程ID以後,使用netstat命令查看其佔用的端口:jsp
netstat -anp | grep 10997
tcp6 0 0 :::43125 :::* LISTEN 10997/java tcp6 0 0 :::2181 :::* LISTEN 10997/java
紅色的爲佔用的端口,LISTEN爲佔用的類型,綠色粗體爲進程IDtcp
參考:ui