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

By | May 15, 2022

Recently I was trying to update/upgrade Ubuntu 21.10 using the apt when I encountered the following error:

E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

A quick resolution that worked for me:

ps aux | grep -i apt
sudo kill -9 17796
ps aux | grep -i apt
rm -rf /var/lib/dpkg/lock-frontend
sudo dpkg –configure -a