Operating System - HP-UX
1821051 Members
2485 Online
109631 Solutions
New Discussion юеВ

Looking for lsof examples

 
SOLVED
Go to solution
Jack C. Mahaffey
Super Advisor

Looking for lsof examples

Got any lsof examples to share? I just installed it and would like to build a quick cheat sheet on using the tool for files, processes, and ports.

I have the binary but no man pages.

Jack...
4 REPLIES 4
Massimo Bianchi
Honored Contributor

Re: Looking for lsof examples

Get binay and man pages at:

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.67/

:)

Massimo
Tom Danzig
Honored Contributor
Solution

Re: Looking for lsof examples

A few useful ones -

Check for process usage on port 25:
# lsof -i :25

Check for any process using the /home mount:
# lsof /home

Check what TCP connection a process is using:
# lsof -p -a -i tcp

Get the man page. It's quite descriptive (and lengthy!).
Jeff Schussele
Honored Contributor

Re: Looking for lsof examples

Jack,

Attached is a text file of the man page for lsof v4.55.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Kent Ostby
Honored Contributor

Re: Looking for lsof examples

Here's a sample set of commands to find out how many files each process is keeping open:

#ps -ef | awk '{print $2}' > /tmp/list
#cat /tmp/list | while read pid
>do
>echo $pid >> /tmp/lsof.out
>lsof -p $pid >> /tmp/lsof.out
>done
# cat /tmp/lsof.out | more
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"