Attempting to install packages or update software in Ubuntu using sudo apt update or sudo apt install only to encounter the error: ‘E: Could not get lock /var/lib/dpkg/lock-frontend – open (11: Resource temporarily unavailable)’ and ‘E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?’ blocks all package management. In Debian-based operating systems, dpkg and apt enforce strict single-instance locking to prevent database corruption. This error occurs when another process (such as unattended-upgrades or the GUI Software Updater) is actively updating the system, or when a previous package installation terminated abnormally without releasing lock files.
Why Does Ubuntu Report the dpkg Frontend Lock Error?
Debian package management creates lock files (including /var/lib/dpkg/lock-frontend, /var/lib/dpkg/lock, and /var/lib/apt/lists/lock) whenever modifications are underway. Common causes include:
- Active Unattended-Upgrades Daemon: Ubuntu’s automated background maintenance service (
unattended-upgr) is actively checking for or installing security updates in the background. - GUI Software Centre or Update Manager Running: An open graphical package manager holding the frontend lock during repository indexing.
- Abrupt System Termination During Installation: A power failure, hard reboot, or premature terminal window closure leaving stale lock files on disk after the process died.
- Interrupted Package Configuration: A previous package installation exited with errors, leaving the dpkg status database in a half-configured state.
Step 1: Check for Active APT and DPKG Background Processes
Before deleting lock files, verify whether an automated background maintenance routine is genuinely running.
- Open your terminal and search for running package manager processes:
ps aux | grep -iE 'apt|dpkg' | grep -v grep - If processes such as
unattended-upgr,apt.systemd.daily, ordpkgare running, the system is performing automated security updates. - Wait 2 to 5 minutes for the background service to complete naturally. Terminating active package installations mid-execution risks package corruption.
Step 2: Terminate Stuck Background Processes Safely
If the background process has been hanging for a prolonged period (e.g. over 30 minutes) without activity, terminate it cleanly.
- Find the specific Process ID (PID) holding the lock file:
sudo lsof /var/lib/dpkg/lock-frontend - Send a standard termination signal to allow the process to exit cleanly:
sudo kill -15 <PID> - Wait 10 seconds. If the process remains unresponsive, terminate it forcibly:
sudo kill -9 <PID>
Step 3: Remove Stale Lock Files Safely
Once you have confirmed that no active package management processes are running, delete the orphaned lock files.
- Execute the following commands in sequence to remove all APT and DPKG lock files:
sudo rm -f /var/lib/apt/lists/lock sudo rm -f /var/cache/apt/archives/lock sudo rm -f /var/lib/dpkg/lock sudo rm -f /var/lib/dpkg/lock-frontend
Step 4: Reconfigure DPKG and Fix Broken Packages
After releasing locks, verify the integrity of the dpkg database and finish any interrupted package setups.
- Reconfigure all unpacked but unconfigured packages:
sudo dpkg --configure -a - Fix any missing or corrupted package dependencies:
sudo apt install -f - Update your package index to confirm locks are operating normally:
sudo apt update
Step 5: Disable Unattended-Upgrades (Optional)
If background automated updates frequently disrupt administrative CLI tasks on development servers, disable automatic background upgrades.
- Run the reconfigure dialogue:
sudo dpkg-reconfigure -plow unattended-upgrades - Select No when prompted whether to automatically download and install stable updates.
Allowing background upgrades to complete, removing orphaned lock files, and running dpkg reconfigure restores smooth package installation in Ubuntu.