Query by file

witr --file /var/lib/dpkg/lock

Explains which process holds the file open, and — as with every other target type — the chain that put that process there.

This is the Could not get lock /var/lib/dpkg/lock situation. Knowing the PID is half an answer; knowing that an unattended-upgrades timer holds it tells you to wait rather than to kill.

Repeatable#

witr --file /var/lib/dpkg/lock --file /var/run/app.pid

And mixable with names, PIDs, ports and containers in a single command.

The Locks tab#

The TUI has a dedicated Locks tab showing system-wide file locks:

  • Linux — POSIX and FLOCK locks, read from /proc/locks
  • macOS and FreeBSD — derived from lsof and fstat
  • Windows — not available

Press a inside the tab to switch into all open files mode, where locked entries merge with every interesting open file descriptor on the system. The / search filters across the merged set.

That mode is the one to reach for when you know a file is being touched but not that it is formally locked.

Platform note#

File lock support varies by platform — see the feature matrix. On Windows, query by file still resolves open handles, but lock enumeration is not available.

Query by file — witr