Created
July 14, 2013 19:52
-
-
Save hqmatics/5995636 to your computer and use it in GitHub Desktop.
netstat functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List connections for port | |
netstat -an | grep 12345 | |
# List the number and type of active network connections | |
netstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c | |
# Number of connections for each hosts | |
netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i < $1; i++) {printf("*")}; print "" }' | |
# Number of connections for each port | |
netstat -tuna | awk -F':+| +' 'NR>2{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment