On OS X, I think the locate DB is populated by running:

sudo /usr/libexec/locate.updatedb

But locate does not seem to find anything in or below ~/

Should locate.updatedb be indexing my home folder by default? If so, any suggestions or ideas why it is not? If it doesn't index ~/ by default, are there any reasons to not index this folder hierarchy? If not, how do I configure it to do so?


Also, when I run locate.updatedb from ~/ (as non-root) it works. When I run it from anything below (for example, ~/Desktop/) I get the following errors:

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
find: .: Permission denied
link|improve this question

60% accept rate
Do you use FileVault? – Daniel Beck Jan 24 '11 at 7:42
Nope I do not use FileVault. – mankoff Jan 24 '11 at 7:49
feedback

1 Answer

up vote 3 down vote accepted

Locate runs as the "nobody" user to prevent other users from being able to see "your" files in the locate database. As your account is the only one with permission to explore your files, locate can't see them. Even if your account is the sole local user, this limitation applies. When you sudo the locate.updatedb script, the find command it spawns is specifically started as unprivileged. While you could modify the script to prevent this issue, I can't say it's recommended.

Also, locate is not enabled by default as it is presumes Spotlight/MDS are better for most people. I'd suggest trying out the mdfind command. If you do decide you want locate to run regularly, execute sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist to load its launchd job for regular re-indexing.

link|improve this answer
That last part is right from the uninitialized locate help message, so it's recommended by Apple. – Daniel Beck Jan 24 '11 at 8:24
feedback

Your Answer

 
or
required, but never shown

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