Find which process holds a file lock and free blocked access on a Linux system. 16.01.2026 | reading time: 3 min Locks prevent simultaneous writes and can silently block work; learn how to reveal who holds a lock and what to do next with small, repeatable commands. Reproduce and Inspect Create a test file, hold an exclusive lock in the background, then query lock information with system tools; example commands and sample outputs follow. ```bash # create a file to lock touch /tmp/testfile # acquire an exclusive flock in background flock /tmp/testfile -c 'sleep 300' & # list locks system-wide lslocks ``` ```bash # sample lslocks output (trimmed) COMMAND PID USER MAJ:MIN TYPE SIZE MODE M START END PATH flock 4321 root 8:1 FLOCK 0 excl 1 0 0 /tmp/testfile ``` ```bash # other views lsof /tmp/testfile # sample lsof output (trimmed) COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME flock 4321 root 3u REG 8,1 0 123 /tmp/testfile ``` ```bash # raw kernel locks cat /proc/locks # sample line 1: POSIX ADVISORY WRITE 4321 08:01:123:0 0 EOF ``` Act and Resolve When a lock blocks work, inspect the PID shown by `lslocks` or `lsof`, then decide: ask the process owner to release it, use `flock -u` if you control the process, or stop the process with `kill` if necessary; killing is last resort because it can lose data. Deeper Details Different lock APIs exist: flock, POSIX fcntl locks and mandatory locks behave differently and show up in `/proc/locks` with distinct types; `lslocks` translates those kernel entries to readable rows while `lsof` shows which file descriptor is open; some network filesystems may not report locks reliably. Related Commands You Can Use Try `lslocks` for a quick overview, `lsof` for descriptor context, `fuser` to list PIDs accessing a file, and examine `/proc/locks` for raw kernel information when debugging tricky cases. Next Steps for Mastery Practice on a sandbox: create locks, probe them with different tools, and learn how daemons and NFS interact with locks; mastering these patterns helps troubleshoot real outages and improves daily Linux administration skills. Join Bits & Bytes Academy First class LINUX exam preparation. filesystem utilities processes troubleshooting security