lsof flags & options
-i
List open network connections, optionally filtered by port or protocol.
lsof -i
lsof -i :8080
lsof -i tcp
-p
Show files opened by a specific process ID.
lsof -p 1234
-u
Show files opened by a specific user.
lsof -u www-data
lsof -u ^root
-c
Show files opened by processes matching a command name.
lsof -c nginx
lsof -c python
+D
Recursively list all open files under a directory.
lsof +D /var/log
-t
Output only process IDs (useful for piping).
lsof -t -i :3000
kill -9 $(lsof -t -i :3000)
-n
Don't resolve IP addresses to hostnames.
lsof -n -i :443
-i4, -i6
Show only IPv4 or IPv6 connections.
lsof -i4
lsof -i6