Under Linux and Windows how to see if a port is listening and which process is listening to the command __linux

Source: Internet
Author: User
Use the scene: often we install their own module after the start to discover that a certain port is occupied, in order to ensure that their process can start normally, need to find out who occupied the port, and kill the process, and then start their own process, the specific methods of operation are as follows:

The Linux platform uses the following

: Using the lsof command, you can download the Lsof component under the CentOS platform through Yum install Lsof, and here is to see if Port 11,000th is listening and who is taking it.

Lsof-i: 11000
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
Python 9760 root 8u IPv6 29450 0t0 TCP *:irisa (LISTEN)


You can also use the following command:

[Root@mailmeta1 ~]# lsof-npi:22
COMMAND PID USER FD TYPE DEVICE size/off NODE NAME
sshd 1136 root 3u IPv4 16769 0t0 TCP *:22 (LISTEN)
sshd 1136 Root 4u IPv6 16771 0t0 TCP *:22 (LISTEN)
sshd 28898 root 3u IPv4 981115 0t0 TCP 192.168.28.67:22->192.168.10.126:39868 (established)
sshd 29028 root 3u IPv4 981928 0t0 TCP 192.168.28.67:22->192.168.10.126:40903 (established)
sshd 29222 root 3u IPv4 1002527 0t0 TCP 192.168.28.67:22->192.168.10.112:24322 (established)
sshd 29234 root 3u IPv4 1002721 0t0 TCP 192.168.28.67:22->192.168.10.112:24631 (established)
sshd 29534 root 3u IPv4 1003223 0t0 TCP 192.168.28.67:22->192.168.10.112:28523 (established)
sshd 29744 root 3u IPv4 1003842 0t0 TCP 192.168.28.67:22->192.168.10.182:2496 (established)
sshd 29772 root 3u IPv4 1004044 0t0 TCP 192.168.28.67:22->192.168.10.182:2501 (established)


Windows uses Microsoft's own system commands, as follows: The first step is to use Netstat to see which process PID is occupied by the port: C:\users\xxx>netstat-ano|find "443"
TCP 0.0.0.0:443 0.0.0.0:0 Listening 183236
TCP 192.168.10.126:51593 115.239.210.27:443 established 18460
TCP 192.168.10.126:51604 115.239.211.112:443 close_wait 18460
TCP 192.168.10.126:51605 115.239.211.112:443 close_wait 18460
TCP 192.168.10.126:51606 115.239.211.112:443 close_wait 18460
TCP 192.168.10.126:51607 115.239.211.112:443 close_wait 18460
TCP 192.168.10.126:51610 58.215.118.33:443 close_wait 18460
TCP 192.168.10.126:51611 58.215.118.33:443 close_wait 18460
TCP 192.168.10.126:51641 101.201.169.146:443 close_wait 18460
TCP 192.168.10.126:51642 101.201.169.146:443 close_wait 18460
TCP 192.168.10.126:51671 115.239.211.112:443 established 70704
TCP 192.168.10.126:51672 115.239.211.112:443 established 70704
TCP [::]:443 [::]:0 Listening 183236
In the second step, use window's tasklist command to view the PID's process name: C:\USERS\XXXX>TASKLIST/FI "pid eq 183236" image name PID session name Session # Memory Usage
========================= ======== ================ =========== ============
Vmware-hostd.exe 183236 Services 0 24,256 K
Then find the process in Task Manager and manually kill it.
 

Related Article

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.