09 July 2006

lsof

lsof is a very useful diagnostic command:

# show whose listening on sockets
lsof -i -P

# which processes are using a file
lsof /mnt

# which process is holding localhost:80
lsof -i TCP:80

# show handles associated with a process 30563
lsof -p 30563

# show handles associated with a process syslogd
lsof -c syslogd

# show files associated with user sekhonp
lsof -u sekhonp