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?

  • 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 Mar 10 '14 at 11:40
  • Thanks but when I enter it, it still says Permission denied – Papadopolous Mar 10 '14 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 Sep 3 '14 at 14:45

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.


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


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


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.

protected by goldilocks Sep 27 '15 at 12:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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