Thursday, March 24, 2011

View all network connections on OS X

If you're interested in seeing which of your Mac applications are connected to the internet you can try running the lsof (list open files) command.

1. Open Terminal.app (found in Applications -> Utilities)
2. Type lsof -i
3. Hit ENTER

lsof will now show you the list of network connections. If you have administrative rights you can run "sudo lsof -i" to see *all* connections, even those made by system processes such as daemons.

lsof outputs a variety of information by default but we're mostly interested in:

  • COMMAND - The name of the command or program
  • PID - Process ID of the connected program, you can use this to get more information about the program later. e.g You can look for this PID in Activity Monitor.app to see more statistics
  • USER - The name of the user running this app, usually this is your user name or "root" if the process is a system service/daemon
  • NAME - The address and port the application is connected to. If you see something similar to *.* or *: that means the application is listening for connections.

No comments:

Post a Comment