Dave's Brain

Browse - computer tips - using lsof to see network activity

Date: 2008apr15
OS: Linux

Q.  What's an alternate way to see network activity?

A.  Use lsof - which stands for List Open Files.
Sounds weird, huh?  But on Linux/Unix everything is a file -- even
network connections!

Here are some some uses.
All TCP/IP connections:

	lsof | grep TCP

All IPv6 connections:

	lsof | grep IPv6

Or

	lsof -i6

If you don't want any IPv6 running see my tip on disabling it:
http://www.davekb.com/search.php?target=disable+IPv6

What's Apache doing:

	lsof | grep httpd

(Lists files it has open and network connections - nice)

lsof has many options.  But I prefer simply grep-ing.
If you aren't root some files will be unavailable.

Add a comment

Sign in to add a comment
Copyright © 2008, dave - Code on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License.