0

I have a problem with my apt-get routine. Problem is, I have sudo and want to update/upgrade, yet I get a "permission denied". Looks like 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?

Looked for running processes blocking that file, found none. Rebooted the system, no change. Any other explanation and fix for this problem?

Question is a possible duplicate of Permission denied, are you root?, yet I was advised to ask it again... (This question doesn't answer MY question)

Xenonite
  • 111
  • 1
  • 6
  • The error message as provided shows a likely user error in the command, but you've not provided your actual command thus it's currently unclear. Please provide command & error message in the same paste. – guiverc Nov 02 '22 at 22:02
  • No, it doesn't, as stated in my question already – Xenonite Nov 03 '22 at 09:54
  • So you tried this answer - and closed software center and anything else that might use apt? – Artur Meinild Nov 03 '22 at 10:02
  • It's still a duplicate. Maybe a new solution should be added to the existing answer - but rather to the existing thread than here - because this is how the site works. – Artur Meinild Nov 03 '22 at 10:03
  • Something else is using dpkg like an automatic update or you killed a process that was using dpkg and the lockfile is in place to prevent other processes from using dpkg until the original process is finished. This is to prevent conflicts in package management. You can check which process (if any) is using dpkg by using sudo lslocks. The name of the process will be listed on the left. – mchid Nov 03 '22 at 10:21
  • Next (for example, if apt was the process shown in the previous step), use pgrep -l apt to check if the process is actually running. If and only if the process is not running and your pgrep command returns nothing, then you can safely delete the lockfile using sudo rm /var/lib/dpkg/lock – mchid Nov 03 '22 at 10:23
  • Long story short, if a process is currently using the lockfile, then you should wait. However, if there is no process actually using the lockfile, then you can safely delete the lockfile and then go about your business. – mchid Nov 03 '22 at 10:25
  • Also it should be noted that if the sudo lslocks command returns anything, then you can safely delete the lockfile. – mchid Nov 03 '22 at 10:27
  • @artur-meinild my thought exactly. yet i was told to open another question for this. – Xenonite Nov 04 '22 at 09:05

0 Answers0