Count how many processes hold a file on a linux system

287 views Asked by At

I am intersted to know how many processes or any other entity whatsover, holds a specific file on the system. I tried to find a way using lsof (I don't want to aggregate all the holders for effectiveness reasons), but couldn't find anything in the man page.

Please note that I don't mean the inode link count that is counting the hardlink count for this specific file on the fs.

Edit: I know now it is possible to use fuser (mentioned in one of the answers below) to get this information, but fuser uses procfs and therefore it is not very efficient. Does anyone knows of any other tool which doesn't iterate procfs?

Thanks.

1

There are 1 answers

1
devadrion On BEST ANSWER

Try using following command

fuser filename

You can also try

lslocks