Skip to content

Instantly share code, notes, and snippets.

@zbowling
Created August 10, 2012 21:47
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zbowling/3318310 to your computer and use it in GitHub Desktop.
Save zbowling/3318310 to your computer and use it in GitHub Desktop.
Mountain Lion "locate" fix.

One of my favorite commands on most unix systems is the locate command which ships with the system. After upgrading Apple seems to have completely broken it.

It appears the built /usr/libexec/update.localdb script looks for a nobody user on Mountain Lion (this is the same version of this script since Snow Leopard). This user seems to be missing after an in-place Mountian Lion upgrade but may be missing in regular installs as well. Apple didn't seem to check to see if the locate script (Apple use's the version from FreeBSD) still worked after changing the default users in the local ldap on your machine. The locate.update script needs the user id for "nobody" to mark as the owner of the database files it creates.

Instead of modifying this script I found it easier to bring back the nobody user. This also fixes mysql upgrades from lion as well.

(nobody user on Lion was user 13)

sudo dscl . -create /Users/nobody
sudo dscl . -create /Users/nobody UserShell /usr/bin/false
sudo dscl . -create /Users/nobody Realname "Unprivileged User"
sudo dscl . -create /Users/nobody UniqueID "13"
sudo dscl . -create /Users/nobody PrimaryGroupID: "-2"
sudo dscl . -create /Users/nobody NFSHomeDirectory "/var/empty"

If it works, then you can run this to reload your updatedb manually:

sudo /usr/libexec/locate.updatedb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment