lsof

Table of Contents

lsof reference

lsof         # files opened by processes
lsof -i      # opened internet sockets
lsof -i :80  # opened internet sockets on port 80
lsof -i udp
lsof -i tcp
lsof -i tcp:80
lsof -p 4455 # opend by pid 4455

sudo lsof /usr/sbin/httpd  # opened by httpd
sudo lsof "$(which httpd)"

# by pattern
lsof -c h
lsof -c httpd
lsof -c Dropbox
lsof | grep httpd
lsof -c bash

# by user
lsof -u tommy
lsof -u _www
lsof -u root

$ lsof -n -P # numeric ip(-n) and port(-P)