Linux uses the port number to query the occupied process and know where it is

Source: Internet
Author: User
Tags zookeeper

For example, to query port 2181.

1. The process ID that the query port occupies

NETSTAT-ANP | grep 2181
TCP6       0      :::2181                 :::*                    LISTEN      10997 

2181 as port number

10997 for PID

You can also use:

lsof-i:2181
COMMAND   PID USER   FD   TYPEDEVICE size/OFF  NODE namejava    10997  Jim   25u  IPv6 197822      0t0  TCP *:2181 (LISTEN)

2, according to the PID query process location

10997
Jim109971959 0 December 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

Reference:

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

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

Linux uses the port number to query the occupied process and know where it is

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.