0

I have a similar problem as this

When doing apt-get update I got

apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

apt-get upgrade E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

However in that question everybody answered "use sudo" which yes, it permits the execution but it is not an answer because:

  • Previously in my PC I could do update and upgrade without sudo. So I would like to know how to be able to do update and upgrade without sudo again

edit: The solution is not using sudo all the time. For reference check this article or this article which actually try to solve the problem (unfortunately their solution didnt work for me but it goes in the direction of the problem)

Edit2. One other reason why sudo *should not be * necessary is the following: I use a lot of docker images. When you build a docker image you use a Dockerfile. In the docker file you have things like

RUN apt-get update && apt-get remove -y x264 libx264-dev
RUN apt-get update && apt-get upgrade -y && apt-get install -y sudo clang-format wget apt-utils

if sudo were necessary, then we could not build docker images at all. So far I have build several of these because sudo was not necessary.

1 Answers1

3

The default for apt-get update is requiring sudo. If your system did not require it at a given point (and that is typically not a good idea), that is because someone did something.

If you want to recover that behaviour, thinking that it should be the default and somehow it changed, I suggest you reconsider the idea, and stick with sudo apt-get update.

If you are aware of the risks involved, and you still want apt-get update without sudo, you can open a terminal and type sudo visudo. At the end of the file (really the last line in it) type %yourusername% ALL=NOPASSWD: /usr/bin/apt-get install where %yourusername% is replaced by your username (source). That still requires sudo but it does not prompt for a password.

terdon
  • 104,119