Which terminal command is preferable to reindex the internal SSD, mdutil -E or mdutil -X followed by mdutil -i?

M1, Monterey

In my effort to develop good habits, I want to reindex the internal SSD using a terminal command instead of going through sys pref → spotlight → privacy → add then delete the internal SSD.

This approach will help me make a habit of using terminal commands

I was told that there are 2 ways to reindex with terminal commands and that both methods are different, although it’s not clear what the difference is

method 1
mdutil -E

Method 2
mdutil -X followed by
mdutil -i

What is the difference and which one do you recommend ?

thanks in advance for your time and help


As I read the man page, you want:

mdutil -X

-X does not disable indexing, so mdutil -i is not needed.
-i is a toggle, so in this case it would turn off indexing.
-E is for clearing other meta-data rather than the Spotlight index.

Enter this for more info:

man mdutil

1 Like

thanks very much. My apologies ! I did no think of reading the manual !

The Spotlight index is included in “local store for the volumes indicated to be erased” and is one of the ones that is rebuilt thereafter. This used to be the only option available to rebuild the Spotlight database.

The -X option is relatively new, with the difference being that Spotlight isn’t rebuilt until the volume "is unmounted and remounted, the machine is rebooted, or an explicit index command such as ‘mdutil -i’ or ‘mdutil -E’ run for the volume.

The -i option will only rebuild the Spotlight database if it was previously turned off. I would guess that the -X turns it off which is why it needs to be followed by a -i command for rebuilding to start without having to uncounted/remount the volume or restart.


@alvarnell @Will_B

Thank you @alvarnell for your post. At the risk of irritating you, things are still not clear.

Background: there is a Spotlight Monterey bug: after migration, in Finder, you can only search user home + Volumes. You can’t use the search/find function on a single folder. To do so, you have to reindex spotlight after migration.

I know because I encountered the bug and had the opportunity to ask an indexing expert (writes search apps which rely on spotlight).

The expert in question mentioned something interesting about indexing which I wanted to clarify in this forum. I will not mention his name for privacy reasons.

The conventional way of indexing is sys pref → spotlight → privacy → add then delete the internal SSD from the privacy window.
The expert told me that this is equivalent to mdutil -E. Do you agree ?

In addition, he told me that a more in depth re-indexing (my words) which additionally deletes index related meta-data can be achieved by
mdutil -X followed by mdutil -i which make sense after reading @alvarnell 's post.

I would like to understand in which way mdutil -X followed by mdutil -i provides more “in depth” (my words) indexing and do you recommend it instead of sys pref or mdutil -E to rebuild the index.

thank you very much

I do, and that has been true for as long as I can recall, probably since the introduction of Spotlight.

I do not know what all is included as metadata removed by the -X option, only that it includes the .DS_Store folder file that stores custom attributes of its containing folder, such as folder view options, icon positions, and other visual information. If you suspect that one or more .DS_Store files have somehow become corrupt, then -X followed by -i would seem to be appropriate, otherwise System Preference/Settings or -E should suffice.

Full disclosure: I am not a day-to-day macOS Monterey user, so my responses are driven by reports from other users and Apple documentation.


thank you very much. It’s all clear now. I am grateful for your time and expertise

@alvarnell @Will_B

Hello, just for the benefit of forum members reading this post, I think that the command is

mdutil -i on , not just mdutil -i

thank you

I mentioned earlier that the mdutil -i commmand will toggle the current status (off to on or on to off) and surmised that the mdutil -X command must turn it off.

Although it won’t hurt to use mdutil -i on, it would appear that’s not really necessary. I earlier googled several examples where Apple and others said it was simply mdutil -i after a mdutil -X.


Understood. thanks very much !

Here some interesting artcles for the problems:

Have a nice weekend


a great reference. thanks very much.