📖 ~1 min read
Table of contents
Symptom & Impact
apt install/upgrade fails with ‘Could not get lock /var/lib/dpkg/lock-frontend’, delaying patching and leaving packages outdated.
Environment & Reproduction
Ubuntu 20.04 LTS host where unattended-upgrades, Software Updater, or another apt process runs concurrently.
Root Cause Analysis
A second package manager process holds dpkg/apt lock files while metadata or package operations are in progress.
Quick Triage
Run ‘ps aux | egrep “apt|dpkg|unattended”‘ and ‘sudo lsof /var/lib/dpkg/lock-frontend’ before killing anything.
Step-by-Step Diagnosis
Confirm active process, inspect ‘/var/log/apt/history.log’, and verify no stale long-dead PID is holding locks.

Solution – Primary Fix
Wait for valid process completion, then run ‘sudo dpkg –configure -a && sudo apt -f install && sudo apt update’.
Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Solution – Alternative Approaches
If truly stale, remove lock files cautiously and immediately reconcile dpkg state with ‘dpkg –configure -a’.
Verification & Acceptance Criteria
‘sudo apt update’ and ‘sudo apt upgrade –dry-run’ complete without lock errors and package DB remains consistent.
Rollback Plan
Restore package lists from backup snapshot and reboot into maintenance shell if dpkg database corruption is detected.
Prevention & Hardening
Schedule maintenance windows, avoid parallel apt tooling, and keep unattended-upgrades timings predictable via systemd timers.
Related Errors & Cross-Refs
dpkg interrupted state, unmet dependencies, and repo metadata mismatches often follow lock mishandling.
Related tutorial: View the step-by-step tutorial for Ubuntu 20.04 LTS.
View all Ubuntu 20.04 LTS tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
Ubuntu Server Guide package management sections, apt man pages, and dpkg recovery documentation.
Need Expert Help?
If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.