How to use netstat command.


What is netstat command?

netstat (network statistics) is a command-line utility used to display various network-related information on a computer. It provides information about active network connections, listening ports, routing tables, interface statistics, masquerade connections, and more. The exact functionality and output of netstat can vary slightly depending on the operating system you’re using.

-a -all : Show both listening and non-listening sockets. With the –interfaces option, show interfaces that are not up

# netstat -a | more 
: To show both listening and 
non-listening sockets.

a0ac4538badbefd5a0a3ca55421f0b04 20230809 120333

List all tcp ports.

# netstat -at 
: To list all tcp ports.

ba23d326831fbaa4d66d27e03251d52b 20230809 120753

List all udp ports.

# netstat -au 
: To list all udp ports.

image 20230809 120911

List only listening ports.

# netstat -l 
: To list only the listening ports.

image 20230809 120955

List only listening TCP ports.

# netstat -lt 
: To list only the listening tcp ports.

image 20230809 121217

List only listening UDP ports.

# netstat -lu 
: To list only the listening udp ports.

image 20230809 121532

List only the listening UNIX ports

# netstat -lx 
: To list only the listening UNIX ports.

image 20230809 121619

List the statistics for all ports.

# netstat -s 
: To list the statistics for all ports.

List the statistics for TCP (or) UDP ports.

# netstat -st(TCP) 
: To list the statistics for TCP ports.
netstat -su(UDP) 
: List the statistics for UDP ports.

Display PID and program names in the output.

# netstat -pt 
: To display the PID and program names.

Print the netstat information continuously.

netstat will print information continuously every few seconds.

# netstat -c 
: To print the netstat information continuously.

The non-supportive address families in the system.

# netstat --verbose 
: To get the non-supportive
address families in the system.
At the end, we have something like this :

The kernel routing information.

# netstat -r 
: To get the kernel routing information.

The port on which a program is running.

# netstat -ap | grep ssh 
: To get the port
on which a program is running.

Which process is using a particular port:

# netstat -an | grep ':80' 
: To get the process
which is using the given port.

List of network interfaces.

# netstat -i 
: To get the list of network interfaces.
Display extended information on the interfaces 
(similar to ifconfig) using netstat -ie:

# netstat -ie
 : To display extended information 
on the interfaces

At NexonHost, we believe that everyone deserves to have their services and applications be fast, secure, and always available.

Follow us

Quick Links

Newsletter

Be the first who gets our daily news and promotions directly on your email.

Copyright © 2025 . All Rights Reserved To NexonHost.