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:

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

# 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.

This entry was posted in Applications & Tools and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted December 29, 2014 at 1:50 pm | Permalink

    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
    Posted March 2, 2015 at 3:52 pm | Permalink

    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
    Posted December 29, 2015 at 2:55 pm | Permalink

    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’)

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.