Last Updated on January 19, 2020 by Christopher G Mendla
I was trying to install ClamAv on two of my Ubuntu machines. I got a ‘could not get lock’ error. A lot of the posts I found said to delete /var/lib/dpkg/lock. DO NOT DO THIS UNTIL YOU EXHAUST ALL OTHER OPTIONS.
I wanted to install clam AV. I received the following error:
chris@chris-VirtualBox:~$ sudo apt install clamav
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?
The posts I found had a number of steps to take including deleting the lock file. I started to think about the situation. Both machines hadn’t been used in a couple of days. One is an Ubuntu laptop and the other is a virtual machine running Ubuntu under Windows 10. It dawned on me that the problem might simply be that automatic updates had locked the lock file.
I filled up my coffee (decaf this time) and tried again. Sure enough, the installs of ClamAV and ClamTk went smoothly.
Takeaway: If you get a ‘could not lock’ error simply wait about 10 to 15 minutes and try again. It might just be the result of auto updates.