1847052 Members
5063 Online
110261 Solutions
New Discussion

Re: lsof question

 
SOLVED
Go to solution
KPS
Super Advisor

lsof question

Hi

I have a need to use lsof to list open files for a specific user on my PA-RISC HP-UX 11.11 box.

I know if I use the fuser -u , that will show the open files that user has. Is there an option using lsof that gives you the actual amount of open files, because that's what I'm really after here.

Thanks,
KPS
7 REPLIES 7
Coolmar
Esteemed Contributor
Solution

Re: lsof question

lsof -u username will list the open files by that user...so if you do the following:

# lsof -u username |wc -l

That will give you the number of files opened by a particular user. Is that what you were looking for?
spex
Honored Contributor

Re: lsof question

Hi,

I think you meant 'lsof -u '. How about:

# lsof -u user1 | wc -l
for a count of user1's open files, and

# lsof | wc -l
for a system-wide count?

PCS
Sandman!
Honored Contributor

Re: lsof question

lsof takes the same option as fuser...

# lsof -u
Calandrello
Trusted Contributor

Re: lsof question

friend
lsof |grep process name
KPS
Super Advisor

Re: lsof question

Thanks everyone, piping this to a wc -l is the way to go. Thanks!
spex
Honored Contributor

Re: lsof question

fuser(1M):
-u Display the login user name in parentheses following each
process ID.

lsof(8):
-u s This option selects the listing of files for the user whose
login names or user ID numbers are in the comma-separated set
s - e.g., ``abe'', or ``548,root''. (There should be no
spaces in the set.)

Coolmar
Esteemed Contributor

Re: lsof question

Hi again,

Would you be so kind as to assign points to any that helped you.
:0)