How do I add a directory to be indexed by
locate.updatedb on macOS / BSD so that I can find files in that directory with the
I read the man page of
locate(1) on Mac, but didn't find anything useful.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
locate(1) man page tells you how to use the
locate command to look stuff up. As the indexing is done by
locate.updatedb, you should read the
locate.updatedb(8) man page instead.
But on a macOS Big Sur at least, the information relevant to your question is rather limited. Basically it just says:
The contents of the newly built database can be controlled by the
By default, all the settings in
/etc/locate.rc seem to be commented out. The relevant lines for your question are:
# directories to be put in the database #SEARCHPATHS="/" # directories unwanted in output #PRUNEPATHS="/tmp /var/tmp" # filesystems allowed. Beware: a non-listed filesystem will be pruned # and if the SEARCHPATHS starts in such a filesystem locate will build # an empty database. # # be careful if you add 'nfs' #FILESYSTEMS="hfs ufs apfs"
Assuming the file follows the convention of presenting the default settings as commented-out examples, it seems that everything located on HFS, UFS or APFS filesystems will be indexed by default, except the contents of
If the directory you wish to add is located on one of those filesystem types, and is not under
/var/tmp, the directory should automatically get indexed the next time
Note that many variants of
locate will check for access permissions when displaying the results, and will only show you files you would have permission to see.