/var/db/locate.database does not update.

The locate.db does not update,

verified file was empty

verified command was run by root at top of filesystem


The following transcript (with comments added) reflect all the troubleshooting steps I have found thus far.

-------------------------------------------

#Ensure I am at the top of file system

MackBook-Pro:~ root# cd /

 

#Check locate.database

MackBook-Pro:/ root# cksum /var/db/locate.database

4294967295 0 /var/db/locate.database

 

#Make sure it is really empty

MackBook-Pro:/ root# cat /dev/null > /var/db/locate.database

 

#(info: Notice how it didn’t change)

MackBook-Pro:/ root# cksum /var/db/locate.database

4294967295 0 /var/db/locate.database

 

#Check to make sure it is writable

MackBook-Pro:/ root# ls -l /var/db/locate.database

-r--r--r-- 1 nobody wheel 0 Jun 11 09:14 /var/db/locate.database

 

#Make it writable by anybody (for troubleshooting)

MackBook-Pro:/ root# chmod a+w /var/db/locate.database

 

#Verify it is writable by everybody

MackBook-Pro:/ root# ls -l /var/db/locate.database

-rw-rw-rw- 1 nobody wheel 0 Jun 11 09:14 /var/db/locate.database

 

 

#last check to verify cksum

MackBook-Pro:/ root# cksum /var/db/locate.database

4294967295 0 /var/db/locate.database

 

#update the locate.updatedb

MackBook-Pro:/ root# /usr/libexec/locate.updatedb

 

#Confirm: No data entered. Permissions seem to change back

MackBook-Pro:/ root# ls -l /var/db/locate.database

-r--r--r-- 1 nobody wheel 0 Jun 11 09:16 /var/db/locate.database

 

MackBook-Pro:/ root# cksum /var/db/locate.database

4294967295 0 /var/db/locate.database


#Not that I expected this to work, but this produces the original error presented. 

MacBook-Pro:/ root# locate jpeg

locate: locate database header corrupt, bigram char outside 0, 32-127: -1

 

 

MacBook-Pro:/ root#


--------------------------------


MacBook Pro (M1, 2020)

Posted on Jun 11, 2023 7:37 AM

Reply

Similar questions

12 replies

Jun 18, 2023 10:22 AM in response to gmcgreevy

gmcgreevy wrote:

Well to clarify a bit, mdfind behaves like I would expect “locate” to, with the exception of searching within “Photos Library.photoslibrary”.

Not exactly all-encompassing, but at least I know how to search the file system.


mdfind is far more powerful, as it is the command-line UI into the Spotlight metadata database.


man mdfind for syntax details, and the following for a different overview: https://bryce-s.com/mdfind/

Jun 12, 2023 7:48 AM in response to gmcgreevy

gmcgreevy wrote:

The locate.db does not update,
verified file was empty
verified command was run by root at top of filesystem

The following transcript (with comments added) reflect all the troubleshooting steps I have found thus far.
-------------------------------------------
#Ensure I am at the top of file system
MackBook-Pro:~ root# cd /
 
#Check locate.database
MackBook-Pro:/ root# cksum /var/db/locate.database
4294967295 0 /var/db/locate.database
 
#Make sure it is really empty
MackBook-Pro:/ root# cat /dev/null > /var/db/locate.database
 
#(info: Notice how it didn’t change)
MackBook-Pro:/ root# cksum /var/db/locate.database
4294967295 0 /var/db/locate.database
 
#Check to make sure it is writable
MackBook-Pro:/ root# ls -l /var/db/locate.database
-r--r--r-- 1 nobody wheel 0 Jun 11 09:14 /var/db/locate.database
 
#Make it writable by anybody (for troubleshooting)
MackBook-Pro:/ root# chmod a+w /var/db/locate.database
 
#Verify it is writable by everybody
MackBook-Pro:/ root# ls -l /var/db/locate.database
-rw-rw-rw- 1 nobody wheel 0 Jun 11 09:14 /var/db/locate.database
 
 
#last check to verify cksum
MackBook-Pro:/ root# cksum /var/db/locate.database
4294967295 0 /var/db/locate.database
 
#update the locate.updatedb
MackBook-Pro:/ root# /usr/libexec/locate.updatedb
 
#Confirm: No data entered. Permissions seem to change back
MackBook-Pro:/ root# ls -l /var/db/locate.database
-r--r--r-- 1 nobody wheel 0 Jun 11 09:16 /var/db/locate.database
 
MackBook-Pro:/ root# cksum /var/db/locate.database
4294967295 0 /var/db/locate.database

#Not that I expected this to work, but this produces the original error presented. 
MacBook-Pro:/ root# locate jpeg
locate: locate database header corrupt, bigram char outside 0, 32-127: -1
 
 
MacBook-Pro:/ root#

--------------------------------


Independent of your Terminal commands, what exactly is not working for you as expected?




Can you verify your software is up to date…

The current stable release of Ventura including bug fixes, security updates is macOS Ventura 13.4



Keep your Mac up to date - Apple Support

Keep your Mac up to date - Apple Support





Jun 18, 2023 9:57 AM in response to gmcgreevy

gmcgreevy wrote:

Thank you MrHoffman.

mdfind works great.
I never had to check the link referenced above, because this works perfect. No need to go on.


The man page has the docs needed to get the locate database operational. No URLs needed.


Someone at apple support should take note. (This still seems to have their "senior" support techs are stumped).


Users of Terminal app are mostly comprise development, networking, troubleshooting, and operations folks.


I’d not expect mainline Apple customer support to have particularly much experience with the command shells and related tooling, though Apple developer support will have far more depth here.


No slights intended, too. I started with Unix a very long time ago, and am still learning new things about it.

Jun 18, 2023 10:16 AM in response to MrHoffman

Well to clarify a bit, mdfind behaves like I would expect “locate” to, with the exception of searching within “Photos Library.photoslibrary”.


Not exactly all-encompassing, but at least I know how to search the file system.


Any suggestions or pointers on how to search the Photos Library.photoslibrary from the terminal command line would also be appreciated.



Thanks again.

thanks.

Jun 17, 2023 5:53 PM in response to gmcgreevy

gmcgreevy wrote:

Yes, I can verify Ventura 13.4.

I need very specifically the terminal command to run updatedb / locate.
I have a large number of duplicate files scattered throughout several locations throughout the filesystem, and need to enumerate each, so I can take a hash of each.

The basic updatedb/locate commands do not work as they do on every other linux system.



See if this gets you any closer—

Locate Database - Is it worth generating? - Apple Community


How to update the locate db in macOS Cata… - Apple Community


Trouble with my locate database... "datab… - Apple Community




Jun 17, 2023 6:28 PM in response to gmcgreevy

The basic updatedb/locate commands do not work as they do on every other linux system.

macOS isn’t Linux nor is it based on any version of Linux.

It does have the Unix locate utility, but I haven’t attempted to run it in years.

While Linux is similar to Unix, you should never assume their similarly named utilities work the same.

If you attempt to run locate, it will ask if you want to build the database. Did you try that and did it not work? I can’t tell if you posted all of that because it didn’t work, or you just thought you needed to do what you would do on Linux.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

/var/db/locate.database does not update.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.