The netstat command shows network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
Click to reveal answer
intermediate
What is the main difference between netstat and ss commands?
ss is a newer, faster tool that shows socket statistics and network connections, while netstat is older and slower but still widely used.
Click to reveal answer
beginner
How do you list all listening TCP ports using ss?
Use ss -lt to list all listening TCP ports.
Click to reveal answer
beginner
What option with netstat shows all connections including listening and non-listening?
The option -a with netstat shows all connections, both listening and non-listening.
Click to reveal answer
intermediate
Why might you prefer ss over netstat on modern Linux systems?
ss is faster, uses less CPU, and provides more detailed socket information, making it better for quick and detailed network diagnostics.
Click to reveal answer
Which command shows all listening UDP connections using ss?
Anetstat -lt
Bss -lt
Cnetstat -au
Dss -lu
✗ Incorrect
ss -lu lists all listening UDP connections.
What does the -n option do in netstat or ss?
AShows only established connections
BShows network statistics summary
CShows numeric addresses and ports instead of resolving names
DShows only listening sockets
✗ Incorrect
The -n option prevents name resolution and shows numeric IP addresses and port numbers.
Which command lists all TCP connections including listening and established using netstat?
Ass -au
Bnetstat -at
Css -at
Dnetstat -au
✗ Incorrect
netstat -at lists all TCP connections.
What is the purpose of the -p option in ss or netstat?
AShow the process using the socket
BShow protocol statistics
CShow only passive sockets
DShow port numbers only
✗ Incorrect
The -p option shows the process ID and name using the socket.
Which command is generally faster and recommended for modern Linux systems?
Ass
Bnetstat
Cifconfig
Dping
✗ Incorrect
ss is faster and more efficient than netstat for socket and connection listing.
Explain how to use ss to find all listening TCP ports and the processes using them.
Think about options to show listening sockets and process details.
You got /5 concepts.
Describe the differences and advantages of using ss over netstat for connection listing.
Consider performance and information richness.
You got /4 concepts.
Practice
(1/5)
1. What is the primary purpose of the netstat and ss commands in Linux?
easy
A. To list installed software packages
B. To edit network configuration files
C. To monitor CPU usage
D. To display active and listening network connections
Solution
Step 1: Understand command purpose
Both netstat and ss are used to show network connections and ports.
Step 2: Identify correct function
They do not edit files, monitor CPU, or list software; they show network status.
Final Answer:
To display active and listening network connections -> Option D
Quick Check:
Command purpose = Display connections [OK]
Hint: Remember: netstat and ss show network connections [OK]
Common Mistakes:
Confusing netstat/ss with file editors
Thinking they monitor CPU or memory
Assuming they list installed software
2. Which of the following is the correct syntax to list all listening TCP and UDP ports using ss?
easy
A. ss -tuln
B. ss -a
C. ss --listening
D. ss -x
Solution
Step 1: Understand option meanings
The options -tuln mean TCP (-t), UDP (-u), Listening (-l), Numeric (-n).
Step 2: Match options to goal
To list listening TCP and UDP ports, ss -tuln is the correct syntax.
Final Answer:
ss -tuln -> Option A
Quick Check:
Listening TCP/UDP = ss -tuln [OK]
Hint: Use -tuln with ss to see listening TCP/UDP ports [OK]
Common Mistakes:
Using -a shows all but not filtered to listening
Assuming --listening is a valid option
Using -x which is for Unix sockets, not TCP/UDP
3. What will be the output of the command netstat -tuln | grep ':22' if the SSH service is running and listening on port 22?
medium
A. No output, because port 22 is not shown
B. An error message about invalid syntax
C. A line showing TCP port 22 in LISTEN state
D. A list of all UDP ports except 22
Solution
Step 1: Understand command components
netstat -tuln lists TCP and UDP ports numerically and listening; grep ':22' filters lines with ':22'.
Step 2: Interpret output if SSH runs
If SSH listens on port 22, output will include a line showing TCP port 22 in LISTEN state.
Final Answer:
A line showing TCP port 22 in LISTEN state -> Option C
Quick Check:
SSH on port 22 = netstat output with :22 line [OK]
Hint: grep ':22' filters netstat output for SSH port [OK]
Common Mistakes:
Expecting no output if port is open
Thinking command syntax is invalid
Confusing UDP ports with TCP port 22
4. You run ss -tuln but get no output. What is the most likely reason?
medium
A. The system has no active or listening TCP/UDP ports
B. The command syntax is incorrect
C. No network interfaces are active
D. You forgot to run the command as root or with sudo
Solution
Step 1: Check command correctness
ss -tuln syntax is correct and should show listening ports if any exist.
Step 2: Consider system state
The most likely reason for no output is no TCP/UDP ports are listening, common in minimal containers or systems without bound services. Permissions are not required for ss -tuln.
Final Answer:
The system has no active or listening TCP/UDP ports -> Option A
Quick Check:
No output = no listening TCP/UDP [OK]
Hint: No ss -tuln output means no listening TCP/UDP ports [OK]
Common Mistakes:
Assuming syntax error when command is correct
Thinking no active interfaces means no output
Thinking need root or sudo
5. You want to write a script that checks if port 80 is listening using ss. Which command correctly returns a non-empty output only if port 80 is listening?
hard
A. ss -tuln | grep ':80$'
B. ss -tuln | grep ':80 '
C. ss -tuln | grep ':80'
D. ss -tuln | grep '80'
Solution
Step 1: Understand port matching in grep
Port 80 appears as IP:80[spaces] in ss output before peer address.
Step 2: Compare options
':80 ' matches exactly :80 (port 80 + space), avoids partial matches like :8080. ':80$' fails (not end-of-line). ':80' and '80' match substrings.
Final Answer:
ss -tuln | grep ':80 ' -> Option B
Quick Check:
Exact port match with ':80 ' [OK]
Hint: Use grep ':80 ' to match port 80 exactly [OK]
Common Mistakes:
Using grep ':80$' misses because port not at line end
Using grep ':80' matches ports like 8080
Using grep '80' matches unrelated numbers
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.