Check whether a port in linux is occupied

Source: Internet
Author: User
Netstat-tunlp will display all ports and all corresponding programs. you can use the grep pipeline to filter out the desired keyword segment. list the program viewplainprint occupied by port 22? [Root @ leiwantmp] # netstat-tunlp | grep22 netstat-tunlp displays all ports and all corresponding programs. you can use the grep pipeline to filter out the desired key fields.
List the programs occupied by port 22
View plainprint?
  1. [Root @ leiwan tmp] # netstat-tunlp | grep 22
  2. Tcp 0 0 0.0.0.0: 42957 0.0.0.0: * LISTEN 2230/rpc. statd
  3. Tcp 0 0 0.0.0.0: 22 0.0.0.0: * LISTEN 2443/sshd
  4. Tcp 0 0 127.0.0.1: 631 0.0.0.0: * LISTEN 2292/cupsd
  5. Tcp 0 0: 22: * LISTEN 2443/sshd
  6. Tcp 0 0: 1: 631: * LISTEN 2292/cupsd
  7. Tcp 0 0: 57609: * LISTEN 2230/rpc. statd
  8. Udp 0 0 0.0.0.0: 5353 0.0.0.0: * 2211/avahi-daemon
  9. Udp 0 0 0.0.0.0: 631 0.0.0.0: * 2292/cupsd
  10. Udp 0 0 0.0.0.0: 37167 0.0.0.0: * 2230/rpc. statd
  11. Udp 0 0 0.0.0.0: 52291 0.0.0.0: * 2211/avahi-daemon
  12. Udp 0 0 0.0.0.0: 68 0.0.0.0: * 2207/dhclient
  13. Udp 0 0 0.0.0.0: 710 0.0.0.0: * 2230/rpc. statd
  14. Udp 0 0: 39834: * 2230/rpc. statd


View the usage of a port: lsof-I: port number
[Root @ www ~] # Lsof-I: 21
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
Pure-ftpd 2651 root 4u IPv4 7047 TCP *: ftp (LISTEN)
Pure-ftpd 2651 root 5u IPv6 7048 TCP *: ftp (LISTEN)
Port 21 is being used by pure-ftpd and the status is listen.



Netstat-anp: displays System port usage

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.