Junior
What keys do you use with netstat commands and what do they mean?
sobes.tech AI
Answer from AI
-a: Displays all active connections and listening ports. Includes TCP and UDP connections.-n: Shows addresses and port numbers in numeric form. Disables hostname and service name resolution, which speeds up output.-p: Displays the PID (process name or number) and the program name associated with the socket. Requires superuser privileges on most systems.-l: Shows only listening sockets.-t: Displays only TCP connections.-u: Displays only UDP connections.-s (--statistics): Shows protocol statistics (e.g., TCP, UDP, IP, ICMP).
Usage examples:
# Display all active TCP connections and listening ports in numeric form
netstat -ant
# Display all UDP listening ports with process information
sudo netstat -ulp
# Display TCP protocol statistics
netstat -s -t
# Example output of netstat -ant
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 192.168.1.10:443 203.0.113.5:12345 ESTABLISHED