11 Vote

Linux Error: Could not open lock file - Permission denied

Question by Guest | 2016-10-31 at 23:09

I have just tried to install a package on Linux. For this, I have typed the following command into the terminal:

apt-get install packagename

However, the installation fails. I get the following error message:

E: Could not open lock file /var/lib/dpkg/lock - open
(13: Permission denied)
E: Unable to lock the administrator directory (/var/lib/dpkg/),
are you root?

I have no idea what that could mean or what is going wrong here.

What can I do to fix that?

ReplyPositiveNegativeDateVotes
Avatar
2Best Answer2 Votes

You have to execute the command as administrator to make it work. This is also the reason why there is the question "are you root".

Instead of "apt-get" you have to write "sudo apt-get". With adding "sudo", you are running the following command as admin respectively root.

sudo apt-get install packagename

After pressing the enter key, the terminal will ask you for your root password. If you have entered and confirmed it, the package installation will proceed.
2016-11-01 at 16:30

ReplyPositive Negative
Avatar
00 Votes

That is brilliant. I had cancelled an operation just prior so I was sure the lock was stuck in an inconsistent state and spent ages trying to fix that non-existent problem. Thanks so much!!!
2021-03-04 at 19:31

Positive Negative
Reply
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.