Command for viewing port usage in GNU/Linux

Source: Internet
Author: User
**************************************** *******************

/*************************************** ******************************
* Author: Samson
* Date: 04/08/2014
* Test platform:
* Linux debian-IDS 3.13.7
* GNU bash, version 4.2.37
**************************************** ****************************/

Method 1:

Root @ debian:/home/# netstat-ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
Tcp 0 0 127.0.0.1: 25 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 33223 0.0.0.0: * LISTEN
Tcp 0 0 127.0.0.1: 3306 0.0.0.0: * LISTEN
Tcp 0 0 0.0.0.0: 111 0.0.0.0: * LISTEN
Tcp6 0 0: 1: 25: * LISTEN
Tcp6 0 0: 60042: * LISTEN
Tcp6 0 0: 111: * LISTEN
Tcp6 0 0: 80: * LISTEN
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1119 ESTABLISHED
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1123 ESTABLISHED
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1125 TIME_WAIT
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1112 TIME_WAIT
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1110 TIME_WAIT
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1122 ESTABLISHED
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1114 TIME_WAIT
Tcp6 0 0 111.111.111.120: 80 111.111.111.114: 1117 TIME_WAIT

Method 2:

Root @ debian:/home # lsof-I: 80
Command pid user fd type device size/OFF NODE NAME
Apache2 2301 root 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 2497 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 2498 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 2499 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 2500 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 2501 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 6108 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 6117 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)
Apache2 6118 www-data 4u IPv6 7298 0t0 TCP *: http (LISTEN)

// Mysql default port

Root @ debian:/home # lsof-I: 3306
Command pid user fd type device size/OFF NODE NAME
Mysqld 2992 mysql 10u IPv4 9546 0t0 TCP localhost: mysql (LISTEN)

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.