In this article, I will be demonstrating how to install netstat on Ubuntu. d2@server:~$ sudo apt install net-tools [sudo] password for d2: Reading package lists… Done Building dependency tree… Done Reading state information… Done The following NEW packages will be installed: net-tools 0 upgraded, 1 newly installed, 0 to remove and 60 not upgraded. Need to get 204 kB of archives. After this operation, 819 kB of additional disk space…
netstat -anp | grep ‘tcp\|udp’ | awk ‘{print$5}’ | cut -d: -f1 | sort | uniq -c | sort -n OR netstat -anp | grep ‘tcp\|udp’|grep -vi “wait” | awk ‘{print$5}’ | cut -d: -f1 | sort | uniq -c | sort -n