LFCS Networking Practice Question
Which TWO commands can be used to display listening TCP ports on a Linux system?
⚠ Common exam trap
Candidates often assume `lsof -i TCP` shows only listening ports, but without the `-sTCP:LISTEN` filter it displays all TCP sockets, including established connections, making it incorrect for the specific requirement of listing only listening TCP ports.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
ss -tln
The `ss -tln` command displays listening TCP sockets by using the `-t` flag for TCP, `-l` for listening sockets, and `-n` to show numeric addresses and ports without resolving service names. It reads socket information directly from the kernel's netlink interface, making it the modern replacement for netstat on Linux systems.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
ss -tln
Why this is correct
ss -tln lists listening TCP ports (t for TCP, l for listening, n for numeric).
- ✓
netstat -tln
Why this is correct
netstat -tln also lists listening TCP ports with numeric addresses.
- ✗
nmap -sT localhost
Why it's wrong here
nmap is a scanner, not a tool to display current listening ports.
- ✗
iptables -L
Why it's wrong here
iptables -L lists firewall rules, not listening ports.
- ✗
lsof -i TCP
Why it's wrong here
lsof -i TCP shows all TCP connections, not only listening ports.
Visual reference
Go deeper
Related to this question
About these practice questions
This LFCS question is part of Courseiva's 507-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.