Welcome to the Linux Foundation Forum!

What is a device lock file? (Data distinctions, 2.4)

gacanepagacanepa Posts: 8
edited July 2018 in LFS201 Class Forum

The subject line pretty sums it up. What is a device lock file, what are they used for, and where do I find them inside the filesystem tree?

Thanks in advance.


  • Hi,

    A lock file is a mechanism to prevent/restrict access to a file while it's in use for an application or specific user. You can find some under /va/lock/ , and if you want to find more, you can do a find operation like this:

    find / -name "*.lock"

    You need to use sudo or run it as root.



  • gacanepagacanepa Posts: 8
    edited July 2018


    Thanks a lot for your reply.

    I found several lock files with find:




    But how do I know what file they are restricting access to?

    FYI, I ran file against /var/lib/postfix/master.lock. Since it's plain text, I then inspected it with cat. Since it contains a number I thought that perhaps it was the PID of a process, but it looks like I was wrong:

    Any ideas?

  • Hi,

    It works like "I'm using this resource, so the rest of you are out until I release it". Many times the content will be the PID of the blocking process, but some other times it won't mean that or anything relevant, but it will mean that it's locked.

    So, if you want to know what's the locking process or program you can do 'lsof' with the lock file, so it will show what process is using the file.

    I hope that helps.


  • gacanepagacanepa Posts: 8

    Thank you, Luis! That answers my question.

  • It's a pleasure!



Sign In or Register to comment.