This chunk of code will show you a nice list of ports on which you have something listening.


#!/bin/sh
# listen - parse netstat -an output for listeners
netstat -an | awk '
BEGIN {
printf("%12s\t%5s\t%5s\n", "ADDRESS", "PROT", "PORT#")
printf("%12s\t%5s\t%5s\n", "-------", "----", "-----")
}
/ LISTEN / {
split($4,ip,":")
printf("%12s\t%5s\t%5s\n", ip[1], $1, ip[2])
}
'

Categories: LAMP

Jonathan Adjei

Jon's expertise in web development is legendary and he oversees all technical aspects of our projects from development to hosting (all through the command line!) Jon is excited by the latest techniques and keeps the company on track by finding ways to adopt new practices into our workflow.

1 Comment

Adjei » Useful Linux commands · March 31, 2006 at 2:04 am

[…] List active internet connections ( just servers ) # netstat -l ( without servers ) # netstat -tup or try the useful script noted here […]

Comments are closed.