Use OpenBSD nc to listen on local TCP port 8080.
Do not use UDP mode or remote scan mode.
Which command is appropriate?
nc -l starts listen mode; without -u, it waits for TCP connections on the specified local port.
Detailed explanation
nc -z 127.0.0.1 8080Incorrect. -z tests a port as a client and does not listen.
Incorrect. -z tests a port as a client and does not listen.
nc -u -l 8080Incorrect. -u selects UDP listen mode.
Incorrect. -u selects UDP listen mode.
nc -v 8080Incorrect. It lacks a listen option and a complete destination form.
Incorrect. It lacks a listen option and a complete destination form.
nc -l 8080Correct. It listens for TCP connections on local port 8080.
Correct. It listens for TCP connections on local port 8080.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '-l=listen' 'no -u=TCP' '8080=local port'Expected result
-l=listen
no -u=TCP
8080=local portKey points
- -l means listen
- Without -u use TCP
- -z is for scanning
Notes
- Environment: OpenBSD netcatのoption対応表(socket作成なし)
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.