Which command would you use to view listening ports and current TCP connections on Linux?

Prepare for the eLearnSecurity Junior Penetration Tester exam with our comprehensive quiz platform. Improve your skills with multiple-choice questions, detailed explanations, and exam tips. Get exam ready with ease!

Multiple Choice

Which command would you use to view listening ports and current TCP connections on Linux?

Explanation:
To inspect sockets and their states on Linux, you want a command that lists listening ports and active TCP connections, along with the owning process. Using netstat with options -t, -u, -n, and -p provides that view: -t shows TCP, -u includes UDP as well (not required but harmless), -n outputs numeric addresses to avoid DNS lookups, and -p shows the process ID and program name owning each socket. The resulting output includes entries in the LISTEN state for ports waiting for connections as well as ESTABLISHED entries for current TCP connections, all labeled with the associated program. Other options either target unrelated data, show only listening sockets, or apply to a different OS, so this command best fits the request.

To inspect sockets and their states on Linux, you want a command that lists listening ports and active TCP connections, along with the owning process. Using netstat with options -t, -u, -n, and -p provides that view: -t shows TCP, -u includes UDP as well (not required but harmless), -n outputs numeric addresses to avoid DNS lookups, and -p shows the process ID and program name owning each socket. The resulting output includes entries in the LISTEN state for ports waiting for connections as well as ESTABLISHED entries for current TCP connections, all labeled with the associated program. Other options either target unrelated data, show only listening sockets, or apply to a different OS, so this command best fits the request.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy