One day I was installing Wine in the terminal, but before the installation was finished, I accidentally logged out. when I logged back in, and ran sudo apt-get install wine, it said

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?

And then I searched online for a solution and followed the guide here: dpkg: error: dpkg status database is locked by another process

So basically I removed the lock file,and ran

sudo dpkg - -configure -a

But then when I tried to install wine again, it said

E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/cache/apt/archives/

How can I fix this? I am running Kubuntu 16.04.

marked as duplicate by karel, Anwar, Zanna, Kevin Bowen, David Foerster Nov 2 '16 at 9:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    you exited before apt finished working or still working. give it some time. If should let you install things then. – Anwar Aug 26 '16 at 19:27

I had the same exact issue not too long ago since I closed the terminal while it was still installing packages for a specific program I was installing.

Here's one of the commands to run to see which process is still running:

sudo lsof /var/lib/dpkg/lock

If you get these results:

lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/usr/1000/gvfs
Output information may be incomplete.
dpkg    8276 root    3uW  REG    8,1        0 12192158 /var/lib/dpkg/lock

Run these series of commands to fix the issue:

sudo killall -9 dpkg or <command> from the listed process using it
sudo dpkg --configure -a
sudo apt-get -f install -y
sudo apt-get update && sudo apt-get upgrade -y

Sometimes, the error would indicate that either the terminal or another program, like Deb package installer was closed during the following:

  1. Power outage
  2. Forced power off
  3. Reboot
  4. Exited the program without canceling out the installation (cannot cancel within the terminal)
  5. Hard drive failure
  6. Other issues via hardware or software
  7. Accidentally closing the terminal all together if multiple tabs were open, or the tab with the sudo apt-get install was closed

Have you tried to fully restart the computer? It seems that a process stayed active after your logged out/log back in.

Restarting the computer should stop all process and restore apt-get functionality.

I would recommend running the following commands:

sudo apt-get autoremove wine
sudo apt-get purge wine

Then use the KDE software manager to install wine


Make sure nothing which might look at those databases is running. This includes aptitude, synaptic, update-manager, Software Center, etc. They all use the apt cache at the base of things, and only one can run at a time.

If none are running, then you might have a stale lock file. You might remove that with something like sudo rm /var/cache/apt/archives/lock

Not the answer you're looking for? Browse other questions tagged or ask your own question.