A server administrator is hardening a new Windows server and needs to verify that only the necessary services are listening for network connections. For efficiency, the administrator wants to see a list of all listening ports in a numeric format and identify the associated process IDs (PIDs) without waiting for DNS resolution. Which of the following commands will accomplish this task most effectively?
The correct command is netstat -ano. This command combination is the most effective for the scenario described. The -a switch displays all active connections and listening ports. The -n switch displays addresses and port numbers in numerical format, which avoids the delay of DNS name resolution. The -o switch includes the process ID (PID) for each connection, allowing the administrator to identify which application is using a specific port.
netstat -r is incorrect because it displays the IP routing table, not connection or port information.
netstat -a is incorrect because, while it shows listening ports, it attempts to resolve hostnames (making it less efficient) and does not display the process IDs required by the scenario.
netstat -s is incorrect because it displays per-protocol statistics (e.g., for IP, TCP, UDP) and does not show individual listening ports or their associated processes.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is `netstat`, and what is its primary purpose?
Open an interactive chat with Bash
What is the role of the `-o` switch in the `netstat` command?
Open an interactive chat with Bash
Why is it more efficient to use the `-n` switch with `netstat`?