1

I want a normal user to be able to update the database used by the locate command in Linux. With the previous version of locate (provided by the package mlocate), I achieved this by adding the following entry into /etc/sudoers:

user ALL = (ALL) NOPASSWD: /usr/bin/updatedb

However, this doesn't work with the new version of locate (provided by the package plocate), which prints the following error when running updatedb:

/var/lib/plocate/: Permission denied

What is the simplest way to allow a normal user to run updatedb?

PS: there's a similar question to mine from 2012, but it is for an older package, slocate.

1 Answers1

1

One way to use updatedb w/o sudo is using doas.

doas is configured with /etc/doas.conf. The configuration has a simple structure:

permit nopass <user> as <another user> cmd <command>

For example, my doas.conf:

permit nopass pg as root cmd apt 
permit nopass pg as root cmd dmesg
permit nopass pg as root cmd mount
permit nopass pg as root cmd umount
permit nopass pg as root cmd updatedb

With this I'm able to run commands apt, dmesg, mount, umount and updatedb without sudo. The format of the command on CLI is

doas updatedb

For further info:

Peregrino69
  • 5,004