Spotlight, introduced by Apple with OS X 10.4 Tiger, is a powerful system tool that allows for fast and easy searches of your entire Mac and any attached drives. For single users on secure Macs, it’s one of the best ways to find your files, app data, and even to launch applications. But if you share your Mac with others, or frequently use it in a public place, you may wish to temper Spotlight’s reach. Here are three ways to prevent Spotlight from indexing items on your Mac.
Turn It Off
First, and most bluntly, you can turn Spotlight off entirely. Note that this will also affect your ability to search within most of Apple’s applications, such as Mail and Finder, as they rely on the same Spotlight foundation that we’re about to kill.
Open up Terminal from /Applications/Utilities and enter the following command to kill Spotlight entirely (you’ll need administrative privileges to execute the command):
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
You’ll immediately notice that Spotlight is suddenly impotent, and returns only the generic “Search the Web” and “Search Wikipedia” options for each inquiry. In the screenshot below, you can see the result of a search with the default settings (left), and after entering the above command (right).
So your files are safe from unauthorized searches but, as we mentioned above, you’re also no longer able to search for emails in Mail, or files from within Finder. If you find that this step was a bit too much, enter the following command to restore Spotlight’s functionality.
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
Note that after reenabling Spotlight, it will need to reindex your drive(s), a process that may take a while depending on the size of the drives and the number of changes that occurred since you disabled Spotlight. You can measure the progress of the rebuild by clicking on the Spotlight icon in the menu bar.
Exclude Items Using Spotlight’s Preferences
Instead of turning the whole thing off, you can simply exclude certain drives or folders from Spotlight by using its Preferences. Head to System Preferences > Spotlight > Privacy. Here you can choose which drives or folders to exclude from Spotlight’s index (note that yours may be empty if you only have a single drive in your Mac).
Adding a file or folder to this list will exclude it and its contents from Spotlight, meaning that they won’t appear during a Spotlight or Finder search. To add items, you can either click the plus icon and navigate to the drive or folder you want to exclude, or you can simply drag and drop drives and folders into the list.
To remove items from the list, and thus make them searchable by Spotlight once again, select the item and press the minus icon at the bottom-left side of the list.
This is an easy way to manage Spotlight’s reach, but it includes one critical flaw: anyone with access to your user account can simply head to Spotlight’s Preferences and see exactly what you’ve chosen to hide. It’s like a treasure map to your private files and secrets. Thankfully, there’s still one final option.
Manually Hide Folders Using a Special Extension
The previous methods to prevent Spotlight from indexing items on your Mac covered both folders and drives, but this trick only works with folders and files. To prevent a specific folder or file from being indexed by Spotlight, add a “.noindex” extension to it.
As an example, we have a folder on our Desktop called “Private Documents” containing a file called “Q3 Financial Results.rtf.” By default, searching for this folder or any file within returns a result with Spotlight.
Now we’ll add “.noindex” to the end of the Private Documents folder (“Private Documents.noindex”). The folder and its contents are immediately excluded from Spotlight and any searches fail to return results from the folder.
The benefit of this approach is that these manually excluded items do not appear in the Privacy tab of Spotlight’s Preferences, meaning that those snooping around won’t be able to easily locate your private or sensitive data. In our example, the “hidden” folder was on our desktop, which would still be easy to find by just looking at it. In practice, of course, you’ll want to stick your “.noindex” folders somewhere out of plain sight.
As we mentioned above, this technique works with both folders and files, but we recommend putting your sensitive files into folders and then applying the “.noindex” extension only to that top level folder. This not only saves time (you don’t have to manually change the extensions of multiple files), it also prevents issues with standard application file extensions.
Most users will best served by using a combination of methods 2 and 3: excluding cloned backups via Spotlight Preferences and hiding a select few personal documents with “.noindex,” for example. Regardless, Spotlight is a very powerful tool and it’s good to know that users have the ability to reign it in when necessary.