I was trying to update the locate database, but when input sudo /usr/libexec/locate.updatedb, I got a bunch of errors. When I try to use locate again it would not work. I can’t remember what I did, but I ended up finding out that the locate.updatedb file had been corrupted. I got locate to work again by using Time Machine to recover the locate.database file. But I want to be able to update locate without corrupting the file. How do I fix this?


Open Terminal.app and run the following two commands:

cd /
sudo /usr/libexec/locate.updatedb

The "cd /" part is important as you need to be in a path where the user "nobody" has permissions.

  • Was not running the command in the “/“ directory what most likely corrupted the file? – StrangeRanger Oct 7 '17 at 21:35
  • It shouldn't have corrupted the file, no. – jksoegaard Oct 8 '17 at 8:40

The command to update the database is

sudo /usr/libexec/locate.updatedb

It should get run automatically every week from /System/Library/LaunchDaemons/com.apple.locate.plist but you can run it manually if required.

  • Sorry. That was my fault, I actually put into the terminal “/usr/libexec/locate.updatedb”. I guess I was thinking about where the locate database was when I was writing the question. I changed that part of my question. – StrangeRanger Oct 7 '17 at 21:32
  • And that is nice to know that it updates everyday, thank you. – StrangeRanger Oct 7 '17 at 21:34
  • Is there a way to run this so it is actually synced. Meaning if I delete then things get removed. Also if add, things get added to the index? – momomo Jul 30 at 19:36
  • 1
    @momo you can use mdfind which uses the Spotlight index. Updating the db locate always requires a full filesystem scan, that‘s not something you want to run every few minutes. – nohillside Jul 30 at 19:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .