Display a List of Open Network Connections on the Mac OS X Desktop

Jul 11, 2011 - 10 Comments

Display open network connections on Mac OS X desktop

Using GeekTool and lsof, you can display an automatically updated list of open network connections directly on a Mac OS X desktop. This is tip is a “safe” alternative to the previously mentioned open_ports utility.

The problem with installing and using open_ports is that it is a third party script running as root, and for many users that is unacceptable. Here is a method that is native to Mac OS X and doesn’t even require root access to watch network connections:

First, if you want to discard the GeekTool portion and just get a quick look at open connections, you can quickly list all open network connections with:
lsof -i | grep -E "(LISTEN|ESTABLISHED)"

You could also combine this with the ‘watch’ utility and just keep an eye on open connections in a terminal window.

That portion of the tip has been covered here before regarding lsof, but the next part is geared specifically for GeekTool because it allows a constantly refreshed list of active connections to overlay against your desktop background picture.

Displaying a Active Network Connections on the Mac OS X Desktop

In order to do this, you’ll need to install GeekTool, it’s a free download and is a great addition to any advanced Mac users toolkit.

Assuming you have now downloaded and installed GeekTool, it will appear in your System Preferences. Here is the setup procedure now:

  • Click on “Shell” and drag it to the desktop, resize it to a reasonable area
  • Using the Properties editor, name the newly dragged Shell to something like “Show Connections”
  • Under “Command” paste the following:
  • lsof -i | grep -E "(LISTEN|ESTABLISHED)" | awk '{print $1, $8, $9}'

  • Set your refresh rate to something reasonable, I chose 3 seconds but you can do whatever you want
  • geektool setup for listing open network connections

  • Adjust the font, font color, and font size in accordance to your desktop wallpaper

You will immediately see a printed list of active network connections on your Mac desktop that automatically updates itself, just like the screen shot at the top of this article. No third party scripts or root access required. The GeekTool script comes from the comments on the MacWorld article about open_ports that they didn’t test. Very nice!

.

Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks

10 Comments

» Comments RSS Feed

  1. sourav maitu says:

    This network is very bad .10sakand colligh uftter disconnet on my fon. / or fon colling uftter sakand is one weya.

  2. Jin says:

    I just can’t get this one to work. If I only type in “lsof” with no additional options, it is ok. as soon as I add anything more (even just “lsof -i”) it fails. I tried with other simple shell commands as well and as soon as I add a space, the commands fail in GeekTool. Any thoughts?

  3. […] yet powerful tool without the complexity or the learning curves related to compiling and using the command line tools lsof, watch, open_ports, or wireshark. Highly recommended. stLight.options({ […]

  4. xristy says:

    I’d like to see the Bps for each established connection. I often am wanting to know what processes are consuming what bandwidth on my machine

  5. Mario says:

    Proper way to do this is to issue netstat -a -f inet

  6. JG says:

    This will get even easier with Lion. See “nettop”

  7. d0ta2008 says:

    Great script! I like this one more than openports anyway, it’s simpler to read

  8. Dave says:

    Thank You

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site