Monitor an App's Internet Usage

Monitor an App's Internet Usage

Every once in a while I want to watch how an app is connecting to the Internet from my Mac, but outside of using Little Snitch’s network monitor I’ve not been quite sure how to do that. Today I was introduced to lsof, a Terminal command to list open files. After reading the manual (man lsof) I found this syntax to work very well for me:

lsof -a -i -c Dropbox

The “-a” ANDs the next two options—without it, the following options would be ORed. “-i” restricts the output to Internet “files” and “-c” filters the output to apps those beginning with name. (I’m oversimplifying the explanation for this use case.)

The real utility in using this command is when you couple it with watch. You may need to install the watch command; once you’ve got it, use this syntax to have your Terminal window update periodically:

watch -n 0.5 lsof -a -i -c Dropbox

The “-n” tells watch how often to update; in the example above, it’s every half second. To cancel, tap ctl-C.