Another netstat trick

So, I run GeekTools on my iMac, and I wanted to be able to view all established internet connections on my Mac.


Here’s how I did it.

netstat -abf inet | grep “ESTABLISHED” -C 1 | grep -v “localhost” | sort -rk7


Explanation:


1. netstat -abf inet
Shows me a list of all internet connections


2. grep “ESTABLISHED” -C 1
It filters the netstat output to show only the ESTABLISHED connections, and it keeps the heading by using -C 1 option.


3. grep -v “localhost”
Basically I’m removing any “localhost” lines from the grep output in command 2.


4. sort -rk7
I’m going to (r)everse sort on column (k7). So it displays my output from largest number of bytes transmitted.


The screenshot shows the output on the lower right hand corner.














  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: