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

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

Leave a Reply

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