0
0
Linux CLIscripting~10 mins

netstat and ss (connection listing) in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to list all active TCP connections using netstat.

Linux CLI
netstat [1] tcp
Drag options to blanks, or click blank then click option'
A-r
B-a
C-s
D-n
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-r' which shows routing tables instead of connections.
Using '-s' which shows statistics, not connections.
2fill in blank
medium

Complete the command to display listening sockets only using ss.

Linux CLI
ss [1]
Drag options to blanks, or click blank then click option'
A-l
B-u
C-t
D-a
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-a' which shows all sockets, not just listening ones.
Using '-t' which filters TCP sockets only.
3fill in blank
hard

Fix the error in the command to show numeric addresses with netstat.

Linux CLI
netstat [1]
Drag options to blanks, or click blank then click option'
A-a
B-p
C-n
D-r
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-a' which shows all connections but not numeric addresses.
Using '-p' which shows process info but not numeric addresses.
4fill in blank
hard

Fill both blanks to list all UDP connections with ss and show process info.

Linux CLI
ss [1] [2] udp
Drag options to blanks, or click blank then click option'
A-a
B-p
C-u
D-l
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-l' which shows only listening sockets, missing active connections.
Using '-u' which is redundant since 'udp' is already specified.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps ports to states for TCP connections using ss.

Linux CLI
connections = [1]: [2] for [3] in ss_output if 'tcp' in [3]
Drag options to blanks, or click blank then click option'
Aconn['port']
Bconn['state']
Cconn
Dconn['proto']
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'conn['proto']' as key or value instead of port or state.
Using wrong loop variable or missing it.