netstat(8) -ln4 %7C grep LISTEN %7C grep -v 127 %7C wc -l
Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
-l, --listening
    Show only listening sockets.  (These are omitted by default.)
--numeric , -n
    Show numerical addresses instead of trying to determine symbolic host, port or user names.
--verbose , -v
    Tell the user what is going  on  by  being  verbose.  Especially  print  some  useful  information  about
    unconfigured address families.
source manpages: netstat