Is it possible to run apt housekeeping commands (apt-get autoremove
, apt-get autoclean
) without root user, by granting permission of executing apt/apt-get to a user instead.
It seems that you have to use root/sudo to execute those commands, otherwise it would fail:
$ sudo cat /etc/sudoers
...
%sudo ALL=(ALL:ALL) ALL
%wheel ALL=(ALL) NOPASSWD: ALL
user ALL=(ALL:ALL) ALL
user ALL= (ALL) NOPASSWD: /usr/bin/apt-get
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
user ALL=(ALL) NOPASSWD: ALL
$ /usr/bin/apt-get autoremove
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?