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

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


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

sudo updatedb
|improve this answer|||||
  • 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

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.

|improve this answer|||||

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.