Additional menu

netstat Command Usage on Linux

netstat Command Usage on Linux

Geek Flare Blog post is sponsored by Netsparker Web Application Security Scanner.

netstat (network statistics) is a command-line tool that displays network connections (both incoming and outgoing), routing tables, and a number of network interface statistics.

It is available on Unix, Unix-like, and Windows NT-based operating systems.

netstat is the powerful handy tool to troubleshoot network related issues and following are some of the examples.

To View Only Established Connection

netstat -natu | grep 'ESTABLISHED'

To View, Only Connection is in Listen Status

netstat -an | grep 'LISTEN'

To View Port Number used by PID

netstat -anlp | grep $PID

Show statistics for all protocols

netstat -s

Show kernel routing information

netstat -r

Show which process using particular port

netstat -anlp | grep portnumber

AIX: # netstat -Aan | grep portnumber  (This will display address of Protocol Control Block in hexadecimal)

Once you have hexadecimal then can execute below to get wich process is holding a port number.

rmsock $address_of_pcb tcpcb

Show the list of network interfaces

netstat -i

I hope this helps you to get familiar with netstat commands. If interested in learning about Linux networking then check out this.

Reader Interactions

Chandan Kumar
About Chandan
Chandan Kumar is the founder of Geek Flare. Learn more here and connect with him on Twitter.

Leave a Reply

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