2

I've grown tired of always invoking apt-get update and apt-get upgrade under sudo and typing my password, so I have added the following line to my /etc/sudoers file using visudo:

<myusername> ALL=NOPASSWD: /usr/bin/apt-get

Unfortunately when I invoke apt-get I am met with the following error:

<myusername>@sputnik:~$ 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?

I have tried to add the following (fairly obvious) line to /etc/sudoers too but to no effect

<myusername> ALL=NOPASSWD: /usr/bin/dpkg

What must I do?

2 Answers 2

6

Even with that configuration in /etc/sudoers, you will still need to use sudo to run apt-get as root. The difference is that with proper configuration you will no longer need to type in your password.

0
4

You added apt-get in a way that doesn't ask you for a password, but that doesn't mean apt-get would have enough privileges to run. Since you're running it without sudo, it can't lock the package system.

Try to use an alias:

alias apt-get='sudo apt-get'

If it works, you can make the alias permanent by adding it to your .bashrc file

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .