Using locate in OS X

rwilkerson

Registered
This is driving me crazy. I'm a regular user of locate on my unix boxes, but in OS X it behaves differently in a number of ways. I've created an alias (I use tcsh, in case it matters later) "updatedb" for "sudo /usr/libexec/locate.updatedb" and not that works similarly. I've also installed a root cronjob to update the db regularly. One problem down.

What I'm left with now, though, is the locate syntax itself. If, as my regular user, I run "locate foo" I get an error returned and the usage displayed. If, however, I run "sudo locate foo", I get the results I'm expecting. Shouldn't I be able to run locate as any user? If so, what am I doing wrong?

My locate.database file is owned by nobody:wheel and perms are 644 (rw, r, r).

Any thoughts?

I appreciate it.
 
What's the exact error you get when you run "locate"? Also make sure "locate" isn't aliased to something else. Compare the output of "alias | grep locate" and "sudo alias | grep locate". You might also try creating a new account and seeing if the locate command works there...
 
I don't actually get error, per se. Just the usage display as though "locate foo" didn't fit the "locate pattern" format. I do have locate aliased to "locate -i" (a carry over from my .tcshrc file on linux, but removing that alias changes nothing.
 
... as in "usage: locate pattern"? Make sure also you're not calling a shell script. What does "which locate" tell you?
 
Back
Top