33

Whenever trying to install any software and update manger,

I get an error stating

Package operation failed
The installation or removal of a software package failed

When I run sudo apt-get update I got this result:

conan51xd@conan51xd-Lenovo-B470:~$ sudo apt-get -f install
[sudo] password for conan51xd: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
conan51xd@conan51xd-Lenovo-B470:~$ 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 file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Braiam
  • 67,791
  • 32
  • 179
  • 269
user66498
  • 477
  • run sudo apt-get update in terminal and post its output in your question by editing it. – atenz Jul 12 '12 at 17:30
  • a sudo apt-get -f install entered into the terminal often works but tijybba is right; post the output of apt-get update if my tip does not work. – onse Jul 12 '12 at 17:32
  • 1
    The best advice is to reboot , and try it will run just fine. Don't use update manager , Ubuntu software center or apt-get through command line at the same time. – atenz Jul 12 '12 at 17:42
  • yes,I know,I don't have use all of them at same times but the problem is when I finish updata,I will get this every times. – user66498 Jul 12 '12 at 17:49
  • Hey you forgot the main keyword there , it should be sudo apt-get update. Thats the answer. – atenz Jul 12 '12 at 17:51
  • well you posted the output of sudo apt-get -f install not what i asked ,anyway i guess sudo apt-get update will run fine. Let us know if it works. – atenz Jul 12 '12 at 17:54
  • this should be market as duplicated of this http://askubuntu.com/q/427479/169736 – Braiam Feb 28 '14 at 14:23

4 Answers4

47

E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

This line says you are not authorized to install/update. You need to be root to do it....

You can add sudo before apt-get or you can do sudo -s to be root.

Example: sudo apt-get update

or

sudo -s will consider you as root until you close your terminal.

Then

apt-get update

Kaktarua
  • 1,874
  • 9
    I got the error with running sudo apt update && apt upgrade, where sudo was missing from the 2nd apt statement. – llinfeng Nov 21 '19 at 14:38
  • sudo -s is the command which solves my year long problem on MacOS !! thanks ~! – Franva Mar 15 '22 at 06:29
3
  1. sudo -s (gives the root access)
  2. apt-get update (get the updates)
  3. apt-get upgrade (upgrades the system)

apt-get update && apt-get upgrade doesn't work on every system so run the commands separately.

Benedict
  • 51
  • 1
3

I had the same error, this worked for me:

This error indicates that you (or some program/script) changed the permissions of the file /var/lib/dpkg/status. Please change them back via: "sudo chmod 644 /var/lib/dpkg/status" in order to fix the issue.

I ended up opening terminal:

sudo nautilus

navigating to the folders/files, and changing permissions to

ME - FOLDER:FULL ACCESS / FILES: READ WRITE

ROOT - FOLDER: FULL ACCESS / FILES: READ ONLY

The problem came when my permissions got screwed when trying to fix a kernel issue I had with an Nvidia driver... but that's another story..

I hope this helps...

pst007x
  • 8,052
-2

Run this command:
sudo mv /var/lib/apt/lists{,july12}

sudo apt-get update
Then sudo apt-get upgrade

drake01
  • 3,457
  • This potentially can damage your system. – Braiam Aug 02 '13 at 03:43
  • The answer was written assuming apt package utility. This software has enough code to take care of situations where some other process (mv in this case) fiddles with the directory where apt-get was writing/trying to write (/var/lib/apt/lists here). And if any software being installed on Un*x system doesn't have this safety, we should start writing an if statement to take care of it – drake01 Nov 24 '13 at 03:00