[MacOS] Locate Command fails in Terminal mode

I. Abstract

Users coming from Linux/Unix esteem the locate command, since it is fast and helps configuring and finding the appropriate files on our systems. Apple decided to implement this command a little disregardful. When executing the locate command you will most likely earn errors. The following will show you how to configure the locate database to have no errors anymore.

II. Enable locate command

We assume you have your root account enabled. Open a terminal window and do the following:

  • mac-client$ sudo /usr/libexec/locate.updatedb
    (provide your root password)

Being on Leopard you will receive this warning:

  • >>> WARNING
    >>> Executing updatedb as root. This WILL reveal all filenames
    >>> on your machine to all login users, which is a security risk.

III. Visit our Sponsor

If this article helped you, please consider our sponsor (Google-Adsense) and help us maintaining this project free. Thanks…

IV. Terminal picture

2 thoughts on “[MacOS] Locate Command fails in Terminal mode

  1. Evgeny

    The update command is not meant to be run by root, it is executed by /etc/periodic/weekly/310.locate which takes care of running it as user nobody.

    Maybe a better option would be to run this weekly script, instead of the locate.updatedb command directly.

Leave a Reply

Your email address will not be published. Required fields are marked *