Operating System - HP-UX
1834498 Members
2669 Online
110067 Solutions
New Discussion

In what way lsof is useful

 
SOLVED
Go to solution
V. V. Ravi Kumar_1
Respected Contributor

In what way lsof is useful

hi all,

i have lsof installed on my machine, but i would like know what are all the efficient ways that i can make use of lsof. i have gone through the man page, but better if somebody who can give suggestions how better i can use lsof. (with some examples).

thanks in advance
regds
ravi
Never Say No
5 REPLIES 5
S.K. Chan
Honored Contributor

Re: In what way lsof is useful

S.K. Chan
Honored Contributor

Re: In what way lsof is useful

James R. Ferguson
Acclaimed Contributor
Solution

Re: In what way lsof is useful

Hi:

Here's several, simple uses:

To see all open files of a paricular process (via its pid):

# lsof -p

To see all open files associated with a command:

# lsof -c cron

...or by a logon name:

# lsof -u
# lsof -u

...or what process is using a TCP socket:

# lsof -i tcp:161
# lsof -i udp:161

Regards!

...JRF...
MANOJ SRIVASTAVA
Honored Contributor

Re: In what way lsof is useful

Also suppose a porcess has a port which is hanging , you can grep on the port no. and know which process owned that port no and kill that process to free that port . Genrally help ful in web applications .

man lsof will help you more if you have got it installed.



Manoj Srivastava
Bill McNAMARA_1
Honored Contributor

Re: In what way lsof is useful

when you want to find out whos creating the /tmp/log that is building rappidly,
when you want to unmount a filesystem but it's busy, find out who's using it.. etc..

List open files (remember in unix everything is a file)

Later,
Bill
It works for me (tm)