12

I go to use the updatedb command to update the index and I get

updatedb: can not open a temporary file for `/var/lib/mlocate/mlocate.db'

fyi The locate command is working, e.g.

$ locate Index.xml
/usr/share/mysql/charsets/Index.xml
durrantm.../durrantm$ 

How can I overcome this issue when trying to run updatedb?

21

You have to run the updatedb command as the super user. For example,

sudo updatedb
  • Once created, can the database be updated by a regular user (e.g. from crontab) without super-user privileges? – holdenweb Dec 15 '15 at 12:01
  • 1
    The update db creates the cache file in /var/cache/locate/locatedb, which is only writable by root. So regular user cannot run the command. But it is possible to create a file in different location which is writable by a regular user. (But the problem is regular users cannot read the whole file system) – Manula Waidyanatha Dec 15 '15 at 12:11
0

If you lack time and want to locate a file, you don't need to sudo updatedb in order to update cache. Instead, you can use locate -e filename to skip cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.