brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mdutil -E erases the Spotlight index so the Mac builds a new one

Spotlight
~/tips/tip-macos-mdutil-e-rebuild-spotlight-index

mdutil -s /

Erases the Spotlight index of a volume so macOS rebuilds it from scratch.

When Spotlight lists a file I deleted ages ago, or cannot find one I am looking right at, I do not want to poke around in settings. I want to wipe the index and let the Mac rebuild it.

That is what mdutil -E does. First look at what Spotlight thinks of the volume:

mdutil -s /

That prints the indexing status of the startup volume. Add -a to check every volume. If indexing is on and the results are still wrong, erase the store:

sudo mdutil -E /

The man page says -E erases the local store of each volume you name, and that the stores are rebuilt if appropriate. You can pass another mount point instead of /, for example an external drive at /Volumes/<name>.

Two related options from the same page. -i off or -i on switches indexing for a volume, and the page warns that indexing may be delayed by low disk space or other conditions. -X removes the index directory of a volume without disabling indexing, and the page says Spotlight re-evaluates the volume when it is unmounted and mounted again, after a reboot, or when you run mdutil -i or mdutil -E on it.

The caveat is that erasing is a blunt tool. Until the rebuild is done, searches can be incomplete, and a big drive keeps the Mac busy for a while. I would start it when I do not need Spotlight for a few hours, with the laptop on power, and keep it for results that are plainly wrong.

Further reading: mdutil man page

More Spotlight tips mdimport -i ~/Documents/Invoices Command-2 Files double-click backup-2025.zip unpacks it next to the zip Tab show the Quick Actions for that result "trip to Paris" All Spotlight tips (14) All topics

Link