Home > Applications & Tools > Which Process Holds My File? Tools on Linux and Windows

Which Process Holds My File? Tools on Linux and Windows

Once in a while, I got into issues that my build failed because the IDE could not clean certain folder or file. The root cause was that they were opened by another application/process. If the application is known, just closed it and the build worked well. Some times I had no clue which application held the file. To find out quickly without guessing, right tools are needed.

On Linux, it’s quite easy with a command called lsof as follows:

Time to learn how to "Google" and manage your VMware and clouds in a fast and secure

# lsof /var/log/messages
syslogd 3476 root    2w   REG    8,3 1480 21934417 /var/log/messages

By default, the lsof may not be installed upon typical installation. You can install it easily using package installer. The command on CentOS or Redhat is like the following:

# yum install lsof

On Windows, it’s not hard either if you have the right tool that I will introduce. The tool is called Process Explorer which can be downloaded from this Microsoft link. It’s a bit bigger than 1M in size and quite easy to install.

To find out which process opens a file, you can click Find – Find Handle or DLL menu item, or simply CTRL + F shortcut key. In the dialog box, just enter the path of the file or directory. Upon clicking on Search button, the application names show up in the table below. As with a typical Microsoft tool, you don’t need to think much about how to use it. As the name of the menu suggests, it also find out the applications that use a DLL file.

Categories: Applications & Tools Tags: ,
  1. December 29th, 2014 at 13:50 | #1

    I’m a newbie in Windows apps programming and process explorer for Windows is best and easiest way to find out the process name. Steve I thankyou for sharing this simple tool, I wasn’t aware about it and wasted my 2 hours in searching about processes in task manager and other tools.

  2. Simon
    March 2nd, 2015 at 15:52 | #2

    You can also use sysinternals “Handle” for this if you prefer a command line tool. I have also been trying to find out how to do this using the wmic so appreciate any post on that

  3. MarcoV
    December 29th, 2015 at 14:55 | #3

    Zero points for the windows version unfortunately.

    This only works if you know the exact path. But if you want to know what holds of unmounting of a device it is useless (like lsof |grep ‘mountpoint’)

  1. No trackbacks yet.