Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) or "unable to get exclusive lock"

In the newly installed system I got this massage when I tried to install some package in Ubuntu, even update was also not working.

Some time it happens due to unclean shutdown also.

I thought some package has corrupted so I run “dpkg --configure –a” and “apt-get install –f” but that was not the solution, problem remain same. L

After some time I got the solution…

Lastly I deleted some file which I am mentioning bellow….

1st I delete the lock files....

sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/apt/lists/lock

then apt-get update

.......

If its not solved you issue.. Please try bellow steps.. Thanks fr2632 for your comments..

sudo apt-get install deborphan

and

sudo apt-get autoclean && sudo apt-get autoremove && sudo apt-get remove --purge `deborphan` && sudo dpkg --purge `COLUMNS=300 dpkg -l "*" | egrep "^rc" | cut -d\ -f3`



20 comments:

  1. Your suggestion worked very well. Thanks.

    ReplyDelete
  2. it still doesnt work !!!
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    sss@sss-laptop:~$ sudo rm /var/lib/dpkg/lock
    sss@sss-laptop:~$ sudo rm /var/cache/apt/archives/lock
    sss@sss-laptop:~$ sudo rm /var/lib/apt/lists/lock
    sss@sss-laptop:~$ apt-get update
    E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
    E: Unable to lock the list directory
    sss@sss-laptop:~$

    ReplyDelete
    Replies
    1. its showing open.. close that.. but anyways.. you can remove it as Administrator..

      Delete
  3. did you run "dpkg --configure –a" and apt-get install –f.

    ReplyDelete
  4. :( i recently got this phone and when i typed dpkg --configure –a... it tells me it's password locked.... do u think the other guy whom i bought it from has the password for it?

    ReplyDelete
    Replies
    1. yes.. you should have Administrator or sudo authentication to run that.

      Delete
  5. type
    sudo apt-get update

    ReplyDelete
  6. I change the privilege of the lock files to rw and it flies

    ReplyDelete
  7. Ok, solved with:

    sudo apt-get install deborphan

    and

    sudo apt-get autoclean && sudo apt-get autoremove && sudo apt-get remove --purge `deborphan` && sudo dpkg --purge `COLUMNS=300 dpkg -l "*" | egrep "^rc" | cut -d\ -f3`

    Maybe can be useful to somebody ;)

    ReplyDelete
    Replies
    1. thank for the update bro.. i will update this on the post.. so it can help others.. :)

      Delete
    2. The issue won't gone:

      WhiteHorse@U13.04-desktop:~$ sudo apt-get install deborphan
      sudo: unable to resolve host U13.04-desktop
      [sudo] password for First Strike:
      Reading package lists... Error!
      E: Unable to parse package file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_raring_universe_binary-i386_Packages (1)
      E: The package lists or status file could not be parsed or opened.

      Delete
  8. I have tried all the solution you have mentioned here but i am still getting the same problem

    Tried this :
    sudo rm /var/lib/dpkg/lock
    sudo rm /var/cache/apt/archives/lock
    sudo rm /var/lib/apt/lists/lock

    and this what it returns:
    rm: cannot remove `/var/lib/apt/lists/lock': No such file or directory

    ReplyDelete
    Replies
    1. its can not be remove, because the file is not exist.

      Delete
  9. Sorry Sir but it did'nt worked. I am feeling very frustrated please someone provide a proper solution

    ReplyDelete
  10. Virtualtech: Could Not Open Lock File /Var/Lib/Apt/Lists/Lock - Open (13: Permission Denied) Or "Unable To Get Exclusive Lock" >>>>> Download Now

    >>>>> Download Full

    Virtualtech: Could Not Open Lock File /Var/Lib/Apt/Lists/Lock - Open (13: Permission Denied) Or "Unable To Get Exclusive Lock" >>>>> Download LINK

    >>>>> Download Now

    Virtualtech: Could Not Open Lock File /Var/Lib/Apt/Lists/Lock - Open (13: Permission Denied) Or "Unable To Get Exclusive Lock" >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete

Thank You for your Comments, We will read and response you soon...