Friday, November 23, 2012

netstat -ntlup for OSX - Viewing open network connections

netstat -ntlup is a command i run often in linux to give me a quick run down of what is listening on what port. Unfortunately if you try to do that in OSX is pukes, and cries, and wants its mommy.
Enter lsof - one of the big boy binaries on the lot.
The following command will list all established and listening sockets open on your machine, sorted, along with the process name, the state, the source, and the destination. Needless to say, I like this command:

lsof -i | grep -E "(UDP|LISTEN|ESTABLISHED)" | awk '{print $10, $1, $8, $9}' | column -t | sort

No comments:

Post a Comment