10+ netstat command’s practical usages with example – Unix/Linux

Hi friends, last day we have discussed about some useful switches of netstat. But, in practical situation, we need to use some combination(Switch combinations) to display custom output. Here I am explaining some practical usages of netstat with example.

How to check the status of a Port/Socket ?
Yes, in some situations we need to find out the status of a port on your server, status means if it is Listen or not.
You can use the following combinations to find out the port status.

How to list all port using netstat ?

# netstat -a

List all listening ports?

# netstat -l

List all tcp ports ?

# netstat -at

Example:

# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:mysql                     *:*                         LISTEN
tcp        0      0 *:submission                *:*                         LISTEN

List all udp port ?

# netstat -au

Example:

# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
udp        0      0 host.org:domain  *:*
udp        0      0 localhost.localdomain:domain *:*

List all Unix ports ?

# netstat -ax

List all listening tcp ports?

# netstat -lt

List all listening udp ports?

# netstat -lu

List all listening Unix ports ?

# netstat -lx

List all tcp ports with Process ID and numerically ?
You can use the -n and -p to do the same.

# netstat -atp

List all tcp ports which are in listening status with Process ID and numerically ?
You can use the -n and -p to do the same.

# netstat -ltp

netstat related:
10+ netstat command switches with example – Unix/Linux

Other commands:

Post navigation

Arunlal Ashok

Cloud Infrastructure / DevOps Engineer. I'm dealing Linux servers since 2012. I started this blog to share and discuss my ideas.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

Leave a Reply

Your email address will not be published. Required fields are marked *