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.
sudo
. – vanadium May 21 '21 at 12:12sudo -i
or equivalent to make yourself equivalent to root, meaning you didn't need to usesudo
... however that's generally unwise, and whysudo
is the preferred & safer option. – guiverc May 21 '21 at 12:20