KIM COMPUTER


netstat (Network Statistics)

The netstat command generates displays that show network status and protocol statistics. It is an invaluable tool for finding out which ports are open on your machine and which services are using them.


1. Basic Usage

netstat [options]

2. Key Options (Common Combo: -tulpn)

Option Name Description
-a All Displays all active connections and listening ports.
-n Numeric Shows IP addresses and port numbers as numbers.
-t / -u TCP/UDP Filters by TCP or UDP protocols.
-l Listening Shows only the sockets currently listening for incoming connections.
-p Programs Shows the PID and name of the program to which each socket belongs.

3. Practical Examples

① List all listening TCP and UDP ports with PID

sudo netstat -tulpn

② Checking routing information

netstat -rn

③ Continuous monitoring

Update the statistics every 5 seconds.

netstat -c 5

4. [Tip] The modern alternative: ss

On newer Linux systems, netstat is being replaced by the ss command (Socket Statistics). ss is faster and provides more detailed information.

ss -ant