GPEN · Question #486
You want to find out what ports a system is listening on. What Is the correct command on a Linux system?
The correct answer is A. netstat nap. On Linux, netstat with the correct flags displays all active sockets and listening ports along with the associated process information.
Question
You want to find out what ports a system is listening on. What Is the correct command on a Linux system?
Options
- Anetstat nap
- Bf port/p
- Ctasklist/v
- DIsof -nao
How the community answered
(28 responses)- A82% (23)
- B11% (3)
- C4% (1)
- D4% (1)
Why each option
On Linux, netstat with the correct flags displays all active sockets and listening ports along with the associated process information.
The command 'netstat -nap' uses -n to display addresses and ports numerically without DNS resolution, -a to include all sockets including those in a listening state, and -p to show the process name and PID associated with each socket. This combination provides a complete listing of all ports the system is listening on and which processes own them, making it the standard Linux utility for this specific task.
'f port/p' is not a valid Linux command or utility and does not correspond to any standard network diagnostic tool available on Linux systems.
'tasklist /v' is a Windows command-line tool that lists running processes with verbose output - it does not exist on Linux and does not report network socket or port information.
'lsof -nao' uses an incorrect flag combination for enumerating listening ports - while lsof can show network sockets via 'lsof -i', the -o flag shows file offsets and this syntax does not produce a useful or complete port listing.
Concept tested: Linux netstat flags for enumerating listening ports
Source: https://linux.die.net/man/8/netstat
Topics
Community Discussion
No community discussion yet for this question.