Wednesday, 1 November 2017

How can I determine what process has a file open in Linux?


I'd like to determine what process has ownership of a lock-file. The lock-files are simply a file with a specific name that has been created.


So, how can I determine what process has a particular file open in Linux? Preferably a one-liner type or a particular Linux tool solution would be optimal.



Answer



You can also use fuser for this:


~> less .vimrc
# put in background
~> fuser .vimrc
.vimrc: 28135
~> ps 28135
PID TTY STAT TIME COMMAND
28135 pts/36 T 0:00 less .vimrc

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...