5

Whilst trying to update my Raspberry Pi (with Raspbian OS), I get the following error when I type "apt-get update":

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)

E: Unable to lock directory /var/lib/apt/lists/

E: Could not open lock fike /var/lib/dpkg/lock - open (13: Permission denied)

E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

Is there anything wrong with what I am doing?

3
  • make sure no other app uses apt, then just 'rm /var/lib/apt/lists/lock' and try again ('sudo apt-get update'). Happens sometimes...
    – Gotschi
    Commented Mar 10, 2014 at 11:40
  • Thanks but when I enter it, it still says Permission denied Commented Mar 10, 2014 at 12:00
  • I am not clear understand for this problem. E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
    – user20077
    Commented Sep 3, 2014 at 14:45

4 Answers 4

10

This is caused by you not having the Permissions to get software lock on dpkg. Thus, you need to run the apt-get commands with sudo: sudo apt-get.

If you are still getting this issue after running with sudo, try running sudo rm /var/lib/apt/lists/lock && sudo rm /var/lib/dpkg/lock and then sudo apt-get. Sometimes if a process that has lock on dpkg or apt-get and it quits suddenly, it causes issues, as the lock file isn't removed like it should.

To explain file locks, it's basically a way of keeping certain files and software from being accessed and modified by multiple things (software or people) at once. You can read here for a more in-depth explanation.

From the Link:

File locking is a mechanism which allows only one process to access a file at any specific time. By using file locking mechanism, many processes can read/write a single file in a safer way.

3

have you tried sudo? sudo apt-get update. If so, please check that there is no other application trying to install

2

Very late response but to answer your particular question, if you were running two sudo commands on one line with a '&&' between them as in for example: sudo apt-get update && apt-get dist-upgrade then apparently the first command hasn't released the lock before the second command starts running. In all cases just run them on two separate lines as in:

sudo apt-get update

sudo apt-get dist-upgrade

-2

I have tried this without the root and it gave me the exact same error code. I know the Correct answer, so bear with me please. If you place sudo at the beginning, It give you all access(root). When you install something on linux, it more often then not requires a few protected folders. Protected folders can only be deleted or changed by a root user. You can either put sudo in front of your apt-get update, or you can use the root terminal. I hope this helped.

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