0

I have found recently that when running the Software Updater GUI it automatically, without asking for authentication, updates the local package list, but when running the equivalent in Terminal (apt-get update, or apt update) I get:

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?

So how come through the GUI way you can do the equivalent to apt-get update, and have it run without it asking you for authentication, and in Terminal by simply typing the commands, you cannot?

Is it that the two processes are in fact slightly different, and I am misunderstanding something? Or what? How can I sort of simulate this behaviour in Terminal so that I can run the update command without the GUI (or possibly with if absolutely necessary) and without authentication?

  • Is it using pkexec and doesn't have to ask or something? – Tim Aug 17 '15 at 21:38
  • @Tim: So how would I do the equivalent in Terminal then? –  Aug 17 '15 at 21:39
  • Run pkexec apt-get update maybe. – Tim Aug 17 '15 at 21:41
  • @Tim: Nope, that did not work. I need a way to simulating its behaviour in Terminal so that I can run the update command without it and without authentication. –  Aug 17 '15 at 21:51

1 Answers1

1

Create a personal sudoers file: sudo -E visudo -f /etc/sudoers.d/panda -- I'm going to assume "panda" is your username. The contents are:

panda ALL = NOPASSWD: /usr/bin/apt-get, /usr/bin/apt

Then, you will be able to do sudo apt-get install whatever without needing to enter a password.

glenn jackman
  • 17,900