Error Codes Wiki

Linux dpkg Lock Error — Could Not Get Lock Fix

Warninglinux package

Overview

Fix "Could not get lock /var/lib/dpkg/lock" error on Ubuntu/Debian. Another package manager is running.

Key Details

  • Error: Could not get lock /var/lib/dpkg/lock
  • Tool: dpkg / apt
  • Another process holds the dpkg lock
  • Cannot install or update packages

Common Causes

  • Another apt process is running
  • Unattended-upgrades running in background
  • Previous apt command crashed and left lock
  • System update in progress

Steps

  1. 1Wait — another update may be finishing
  2. 2Find the process: sudo lsof /var/lib/dpkg/lock-frontend
  3. 3Kill if stuck: sudo kill PID
  4. 4Remove lock: sudo rm /var/lib/dpkg/lock-frontend && sudo rm /var/lib/dpkg/lock
  5. 5Reconfigure: sudo dpkg --configure -a

Tags

linuxlinux-packagelinux dpkg lockubuntuterminal

More in Linux Package

Frequently Asked Questions

Only if no apt/dpkg process is actually running. Check with ps aux | grep apt first.