Use ss to list listening TCP sockets numerically and show associated processes where permitted.
Which command is appropriate?
ss -lntp combines listening, TCP, numeric, and process-information filters.
Detailed explanation
ss -lntpCorrect. It lists numeric listening TCP sockets and process information.
Correct. It lists numeric listening TCP sockets and process information.
ss -antIncorrect. It includes non-listening TCP sockets and omits process information.
Incorrect. It includes non-listening TCP sockets and omits process information.
ss -lnupIncorrect. It targets UDP sockets.
Incorrect. It targets UDP sockets.
ss -sIncorrect. -s shows a summary rather than individual listeners.
Incorrect. -s shows a summary rather than individual listeners.
Try it yourself
An example you can run in a temporary verification environment.
ss --help 2>&1 | grep -E -- '-l|--listening|-p|--processes' | head -n 4Expected result
listeningとprocessesに関するhelp行Key points
- -l is listening
- -t is TCP
- -p is process
Notes
- Environment: iproute2 ss help / 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.