netstat -tln | tail -n +3 | awk '{ print $4 }'
it displays the tcp listening endpoint binding addresses. all other endpoints are free; In addition, if on Unix you are not a root user, then you cannot bind to a βprivilegedβ port number (port number below 1024)
explained in more detail:
netstat -tln - all TCP listening ports
tail -n +3 - netstat header cut
awk '{print $ 4}' - print the fourth column consisting of [ip]: [port]
for the general case, you still need to take care to cut out all irrelevant interfaces; The listening address 0.0.0.0 listens on all network cards, if there is an IP address than the specific IP address of the network car / network interface.
source share