Display only listening TCP sockets.
Keep service names as numeric port numbers.
Which command is appropriate?
ss -lnt combines listening, numeric, and TCP filters to show listening TCP sockets with numeric addresses and ports.
Detailed explanation
ss -antIncorrect. It displays all TCP sockets, not only listening sockets.
Incorrect. It displays all TCP sockets, not only listening sockets.
ss -lunIncorrect. It displays listening UDP sockets.
Incorrect. It displays listening UDP sockets.
ss -lntCorrect. It combines listening, numeric, and TCP filters.
Correct. It combines listening, numeric, and TCP filters.
ss -lnuIncorrect. It targets UDP sockets.
Incorrect. It targets UDP sockets.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '-l=listening' '-n=numeric' '-t=TCP'Expected result
-l=listening
-n=numeric
-t=TCPKey points
- -l means listening
- -n means numeric
- -t means TCP
Notes
- Environment: option対応表の表示のみ
- 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.