Ubuntu: Dpkg not working! [duplicate]



Question:

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/

Could someone please help? I am running Kubuntu 16.04.


Solution:1

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


Solution:2

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


Solution:3

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.  COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME  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

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »