Score:0

Permission denied on apt upgrade even though I am root

sa flag

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)

guiverc avatar
cn flag
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.
Xenonite avatar
sa flag
No, it doesn't, as stated in my question already
Artur Meinild avatar
vn flag
So you tried [this answer](https://askubuntu.com/a/427491/1066942) - and closed software center and anything else that might use `apt`?
Artur Meinild avatar
vn flag
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.
mchid avatar
bo flag
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 avatar
bo flag
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 avatar
bo flag
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 avatar
bo flag
Also it should be noted that if the `sudo lslocks` command returns anything, then you can safely delete the lockfile.
Xenonite avatar
sa flag
@artur-meinild my thought exactly. yet i was told to open another question for this.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.