0

I'm trying to execute the command sudo apt-get -y install linux-headers-rpi to install this driver for a pm sensor. However, my raspi gives me this output every time when I execute this command:

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?

I've searched through other post on the forum, and they said that it should be ok once I've reboot it or killed the process that's occupying the file. I did it, but it didn't work. Help?

2

First check if there is a dpkg process running, ps afx|grep dpkg.

If thats the case, kill it with sudo killall dpkg.

Remove the lock file with sudo rm /var/lib/dpkg/lock

That should do the trick.

  • So I first checked if there are any processes running: ps afx|grep dpkg. Result: '18271 pts/0 S+ 0:00 _ grep --color=auto dpkg'. Then I removed the lock file 'sudo rm /var/lib/dpkg/lock'. Now it gives me this: '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?' – Marc Feb 18 '18 at 10:48
  • google "/var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root" – MatsK Feb 20 '18 at 7:01
2

sometimes the error message gives you the pointer to the problem. "Are you root" means you may be trying to run a command without superuser privilege. try running the command preceded with sudo e.g. sudo <command>

  • Please notice that the OP tried the command: sudo apt-get -y install linux-headers-rpi. – Ingo Mar 1 at 11:11
0

This one is old, but I recently had this problem with a freshly written iso.

Expanding the filesystem to use the entire SD card did the trick for me.

As apt-get upgrade might be quite expensive (counting storage). I assume this has been the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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