Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to get a list of pid's which hold shared lock on /tmp/file. Is this possible using simple command line tools?

share|improve this question
up vote 1 down vote accepted

From man lsof:

   FD         is the File Descriptor number of the file or:
              FD is followed by one of these characters, describing the mode under which the file is open:

              The mode character is followed by one of these lock characters, describing the type of lock applied to the file:

                   R for a read lock on the entire file;
                   W for a write lock on the entire file;
                   space if there is no lock.

So R in 3uR mean that read/shared lock is issued by 613 PID.

#lsof /tmp/file
perl    613 turkish    3uR  REG    8,2        0 1306357 /tmp/file
share|improve this answer

fuser /tmp/file will list all processes which have the file open, including those that have a lock on it.

share|improve this answer
Yes, and lsof is also aware of that but flock can refuse locking, or pid could wait for lock after file opening. – mpapec Sep 14 '13 at 11:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.