Linux/window How to view the program/process occupied by a port _unix Linux

Source: Internet
Author: User
Windows:
C:/users/ewanbao>netstat-aon|findstr "123"
TCP 127.0.0.1:55123 0.0.0.0:0 Listening 5092
TCP 127.0.0.1:55123 127.0.0.1:55124 established 5092
TCP 127.0.0.1:55124 127.0.0.1:55123 established 5092
UDP 0.0.0.0:123 *:* 1416
UDP [::]:123 *:* 1416
[note]: After performing netstat-aon|findstr "123", you can see that TCP opens 123 ports in the 5092 process and the 1416 process opens the UDP123 port

C:/users/ewanbao>tasklist|findstr "1416"
Svchost.exe 1416 Services 0 13,540 K
[note]: After performing tasklist|findstr "1416" you can see that Svchost.exe is opening 123 ports on UDP
Linux:
cba001:~ # lsof-i:5300
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Named 26751 root 20u IPv4 64750499 TCP LOCALHOST:HACL-HB (LISTEN)
Named 26751 root 21u IPv4 64750501 TCP CBA001.EAPAC:HACL-HB (LISTEN)
Named 26751 root 22u IPv4 64750503 TCP 192.168.0.10:HACL-HB (LISTEN)
Named 26751 root 512u IPv4 64750498 UDP LOCALHOST:HACL-HB
Named 26751 root 513u IPv4 64750500 UDP CBA001.EAPAC:HACL-HB
Named 26751 root 514u IPv4 64750502 UDP 192.168.0.10:HACL-HB
[note]: After performing lsof-i:5300, you can see that the 26751 process has 5300 ports open on both TCP and UDP.
cba001:~ # Ps-ef|grep 26751
Root 10118 26915 0 12:59 pts/8 00:00:00 grep 26751
Root 26751 1 0 Jul06? 00:02:06/opt/ipworks/ipwdns/usr/bin/named
[note]: After performing ps-ef|grep 26751, you can see that the named process has 5300 ports open

View Process ID
Lsof-w-n-i tcp:8080
Fuser-n TCP 8080netstat-anp|grep:8080[[:blank:]]
Kill the process PID that occupies the port:
Kill-9 Pidnumber

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.