TL;DR: apt / dpkg: “Could not get lock /var/lib/dpkg/lock-frontend” on Ubuntu and Debian
The fix only. No explanation, no diagnosis. Read the full article if any of this does not match what you are seeing.
- The error names the process holding the lock. Look at it (use the PID from your error message).
ps -o pid,etime,stat,cmd -p <PID>
sudo fuser -v /var/lib/dpkg/lock-frontend /var/lib/dpkg/lock- If it is
unattended-upgr,apt.systemd.daily,packagekitdor a software-updater window, wait for it to finish. Or make your command wait for you:
sudo apt-get -o DPkg::Lock::Timeout=300 install <package>- Only if it has run for a long time with no CPU or disk activity, ask it to stop, then repair.
sudo kill -TERM <PID>
sudo dpkg --configure -a
sudo apt-get install -fDo not rm the lock files. The lock belongs to the running process and is released when the process exits. The files staying on disk is normal. Deleting them while something is installing can damage the package database.
- Verify:
sudo apt updateruns with no lock error, andsudo dpkg --auditprints nothing.