Linux Fundamentals: How many services are listening on the target system on all interfaces

Can someone give me a clue for this one please ?

I’ve tried the following commands none have given me the correct answer;

netstat -ano | grep “LISTENING” | wc -l
netstat -ano | grep “LISTEN” | wc -l

I ran the commands on the target system.

try netstat -tulp | grep LISTEN
or
ss -tulp | grep LISTEN

Type your comment> @foalma321 said:

try netstat -tulp | grep LISTEN
or
ss -tulp | grep LISTEN

It tells me that it is not correct.
It also tells me with " netstat -tulp | grep LISTEN ": not all processes can be identified, non-proprietary process information
it will not be displayed, you will have to be root to see it all).

and: what does -tulp mean?

The correct command is:
ss -l -4 | grep -v 127 | grep “LISTEN” | wc -l
-l: show only listening services
-4: show only ipv4
-grep -v 127.0.0: exclude all localhost results
-grep “LISTEN”: better filtering only listening services
wc -l: count results
The tricky part of this question is here :(Not on localhost and IPv4 only).It doesnt want to list listening services on localhost and wants IPv4 only.

This might be a dumb question (I’m very new to Linux) but how would I have known to use the ss or netstat command?

Neither of these were even briefly mentioned in the module where this question lives in the Linux Fundamentals course. Your response definitely got me the correct answer to the question, but I have no idea how I would have gotten there on my own…