who has files open on a linux server
- by Robert
I have the fairly common task of finding who has files open on our Linux (Ubuntu ) file server in our Windows environment.
We use Samba on the network and I use Putty from my workstation to establish a shell window to run bash scripts.
I have been using something like this to find what files are open: (this returns a list of process ids with each open file)
Robert:$ sudo lsof | grep "/srv/office/some/folder"
Then, I follow up with something like this to show who owns the process: (this returns the name of the machine on the network using the IP4 protocol who owns the process)
Robert:$ sudo lsof -p 27295 | grep "IPv4"
Now I know the windows client who has a file open and can take action from there.
As you can tell this is not difficult but time consuming. I would prefer to have a windows application I can run that would just give me what I want.
So, I have been thinking about creating some process I can run on Linux that listens on a port and then returns a clean list of all open files with the IP address of the host who has the file open. Then, a small windows client application that can send the request on the port.
It seems like this should be a very common need but I can not find anything like this that has been done before.
Any suggestions?