See which processes are using the Internet

Be the first to comment | 13I like it!
October 16, 2009, 09:32 PM —  Macworld — 

If you've ever wondered about which programs are using your Internet connection at any point in time, here's one way to find out using Terminal. Open Terminal, in Applications -> Utilities, and run this command:

lsof -P -i -n | cut -f 1 -d " " | uniq

When you press return, you'll see a list of processes that are using the Internet connection; at the time I wrote this, my output looked like this:

$ lsof -P -i -n | cut -f 1 -d " " | uniq

COMMAND

AppleVNCS

PTHPasteb

SystemUIS

aosnotify

iTunes

GrowlHelp

Transmit

iChatAgen

firefox-b

VPNClient

Mail

The first row, COMMAND, is just the column header. Below that are the processes that are using the Internet connection. Most of the time, they are self-explanatory, or can be figured out with relative ease. On my list, most of the entries are pretty clear, but perhaps not aosnotify. A bit of work with Google, though, determines that that process is related to MobileMe syncing.

If you just want to use this command, you know all you need to know now. If you're curious how it works, though, then keep reading.

While the command may look complex, it's actually three relatively simple commands strung together with the pipe (|) symbol. The first one, lsof -P -i -n, runs lsof to list open files, with options set to focus only on those connections using the Internet connection (-i), and to not try to convert port and host numbers into names (-P and -n).

The output from this command is then sent to cut, which cuts out everything except the first field (-f 1), based on using spaces to delimit fields (-d " "). Finally, that output is sent to uniq, which strips out duplicate entries from the list--without this last bit, you'd see a lot of repetition in the list, because every open app will have multiple open files.

And that's all there is to it; thanks to commandlinefu.com for posting this useful tidbit.

» posted by ITworld staff

Macworld

Sign up for ITworld's Daily newsletter
Follow ITworld on Twitter @IT_world

I like it!
Close

On Twitter now

MacWorld

Powered by Twitter
You are logged in | Sign out
Sign in and post to Twitter

What are you thinking?

Cancel Tweet sent

On Twitter now

Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
peer-to-peer

Brian Proffitt
Microsoft/Novell: Breaking Down the Coupon Numbers

Esther Schindler
Drupal's Dries Buytaert on Building the Next Drupal

Tom Henderson
Top Ten General Operating Systems Rants

pasmith
PS3 motion controller delayed; goes up against Project Natal

sjvn
Neolithic Windows security hole alive and well in Windows 7

claird
Perl source code comparison makes for good reading

mikelgan
Cell phones don't create stress or interrupt much

Sandra Henry-Stocker
How to: The Unix Interview

 

Where Google Chrome security fails: the password
I heard mention that the Chrome OS will have some sort of encryption available a la bitlocker. If it's possible to encrypt personal data using another password or key, then it may have potential for very secure data.... And Ubuntu has an 'encrypt home directory' option, perhaps google should follow suit.
- Dann

Join the conversation here

The Daily Tip

The Daily TipQuick, practical advice for IT pros. Made fresh daily.

Hot tips:

Want to cash in on your IT savvy? Send your tip to tips@itworld.com. If we post it, we'll send you a $25 Amazon e-gift card.

Newsletters

Subscribe to ITWORLD TODAY and receive the latest IT news and analysis.

I would like to receive offers via email from ITworld partners.
By clicking submit you agree to the terms and conditions outlined in ITworld's privacy policy.
Marketplace