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 A

Engineer. Linux enthusiast. Traveller. DevOps learner and practitioner. I enjoy working with Linux, DevOps, automation, and technology while exploring new places along the way. I use this space to share my experiences, learnings, experiments, and things I discover along the journey. Whether you're a seasoned DevOps professional or just getting started, let's connect, learn, and grow together. Happy coding, automating, and deploying!

Leave a Reply

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