Symptoms & scope
- APT reports that lock-frontend is held by another process.
- A second package operation waits while an automatic upgrade runs.
Relevant environment
Debian/Ubuntu APT and dpkg, including unattended upgrades; lock inspection may need administrator read access.
Recognizable messages (synthetic examples)
E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2140 (apt)Inspect that PID and transaction; this signature excludes a simple lack of privilege opening the lock file.
Possible causes
These are possible explanations, not a confirmed diagnosis. Several independent faults can coexist.
- Another frontend or automatic update may own the exclusive process lock.
- A stalled package script may keep the lock while waiting for input or another service.
Diagnose safely
Run one command at a time in the relevant session. Read the explanation first. Uppercase placeholders need your own values; tools and privileges vary by distribution. These commands are displayed here and never executed by the website.
Check 1
Reports processes using the existing lock files; do not add -k. Complete results may require root read privileges.
fuser /var/lib/dpkg/lock-frontend /var/lib/dpkg/lockInterpret the result: A PID is a candidate holder; verify that process. No output as an unprivileged user does not prove that no holder exists.
Check 2
Replace PID with the reported holder; reads process state without killing or signaling it.
ps -p PID -o pid,ppid,stat,etime,commInterpret the result: Check whether the expected package manager is still present. Elapsed time alone cannot distinguish a legitimate long script from a hung process.
Evidence-guided next steps
Let an active package transaction finish
If the holder is an active updater, close the duplicate package frontend and let the original transaction finish. Inspect its original terminal or service journal for a prompt or progress, then retry one package operation after the process has released the lock.
Precautions: Never remove dpkg lock files: the lock is tied to the process, and deleting its path can allow concurrent writers.
Recovery / rollback: Waiting needs no rollback. Restart only the duplicate frontend after the original transaction is complete.
Did this solution help you?
Resolve the confirmed stalled job before recovery
If the holder is genuinely stalled, first resolve its identified prompt or failing dependency. If it must be cancelled, use the original frontend’s supported cancellation or an administrator’s controlled termination, wait for all writers to exit, then inspect dpkg --audit before resuming configuration.
Precautions: Do not SIGKILL a package writer simply because it is slow. Cancellation can leave packages unpacked or half-configured.
Recovery / rollback: A cancelled transaction has no universal undo. Resume the audited pending configuration or restore a coherent pre-transaction snapshot if necessary.
Did this solution help you?
References & review
This guide was prepared from primary project or distribution sources and reviewed on the date shown. This is an editorial source check, not evidence that a fix was reproduced on your hardware. Diagnostic log examples are synthetic fixtures. Version-dependent details must be checked against your installed release.
- Debian dpkg team FAQ: lock files must not be removed (project or distribution documentation)
- Debian dpkg: package states, audit and configure operations (project or distribution documentation)
- Debian APT source: dpkg locking and interrupted-state checks (upstream implementation; behavior can vary by version)