Locate command cannot find anything inside Documents folder on mac

As stated in the description. I first check our database up to date

mh547:bin crashandburn4$ sudo /usr/libexec/locate.updatedb Password: #password entered and function executed without errors 

Then I try to find something inside the My Documents folder

 mh547:bin crashandburn4$ cd ~/Documents/ mh547:Documents crashandburn4$ ls Mamp_workspace/ Scenarios.docx gc01/ mh547:Documents crashandburn4$ locate Scenarios.docx #nothing returned 

Then I will try another random folder:

 mh547:Documents crashandburn4$ cd .. mh547:~ crashandburn4$ ls Applications/ Movies/ drawable/ untitled-2.pdf Desktop/ Music/ drawable-xhdpi/ untitled-2.synctex.gz Documents/ Pictures/ dwhelper/ untitled-2.tex Downloads/ Public/ linux_ssh* website-terminal-copy-paste Dropbox/ Samsung/ scripts/ workspace/ Google Drive/ Sites/ untitled-2.aux workspace_copy_to_linux* Library/ android-sdks/ untitled-2.log mh547:~ crashandburn4$ locate website-terminal-copy-paste /Users/crashandburn4/website-terminal-copy-paste #correct result returned 

Can anybody help me? I was stuck on this for an hour and a half or so.

+6
source share
3 answers

As indicated in plundra, because locate OSX ships with the old and crippled ones and does not index and / or not report files that are not readable by nobody , even if they are run with root privileges. However, you can install homebrew and then GNU locate or, as suggested here, use mdfind -name instead (I do not have an OSX operating box to verify this).

+13
source

This is because the Documents folder is not readable in the world, which is good, especially in general systems.

The BUGS locate (1) section of the man-page explains this:

The localization database is usually created by the user "nobody" and the locate.updatedb (8) utility skips directories that are not readable for the user `` nobody '', group '' nobody '' or world. For example, if your HOME Directory is not readable in the world, none of your files are in the database.

Try running ls -ld ~/Documents and you will see permissions. Wikipedia has an article on Unix permissions if you are not familiar with them.

+8
source

You can make sudo ln -s / usr / libexec / locate.updatedb / usr / local / bin / updatedb to make the updatedb command available

+1
source

All Articles