Aptexit code > 0

E: Could not get lock /var/lib/dpkg/lock

$E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)

Analysis

Another process is currently using the APT package management system (e.g., an automatic update or another terminal window running apt).

Common Triggers

  • Running multiple apt or apt-get commands simultaneously.
  • Unattended-upgrades running in the background.

Debug Checks

  • $Find the process holding the lock: sudo lsof /var/lib/dpkg/lock-frontend.

Resolution

1
Wait for the other process to finish.
2
Kill the process (CAUTION): sudo kill -9 <pid> then sudo dpkg --configure -a.

Metadata

Tool
Apt
Severity
High
Tags
#apt#linux#lock