If you’re a Mac user, or manage file shares where Macs are present, you’ve probably seen the .DS_Store file in your file share folders or removable media. The .DS_Store (Desktop Services Store) files are useful for keeping track of metadata and folder settings, like folder view options, sort options, and icon size and position. While browsing these folders from a Mac, you usually won’t see them since adding a dot in front of a file hides it from your Finder view. However, if you’re browsing the same folders from Windows or Linux devices, you’ll see the .DS_Store files all over the place. While they’re small and don’t cause any harm, you may not want to have these files present in your file shares.
You can run a command in MacOS that will prevent the creation of the .DS_Store files, but the Mac users will lose some of the features it provides them, such as their view and sort options for the folders. It will revert back to the defaults every time they navigate to the folder, even if they change the settings again.
Prevent .DS_Store on Network Stores
The change is considered a per-user modification and doesn’t require admin rights. If you’re in a corporate environment, you’ll probably need to script this as a logon script so that it’ll run for each user that logs into a Mac.
- Open Terminal and run this command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
- Reboot your Mac device
If you need to re-enable the .DS_Store creation, run this command and reboot your Mac again:
defaults write com.apple.desktopservices DSDontWriteNetworkStores false
Prevent .DS_Store on Removable Drives
This change is also a per-user modification, so it’ll need to be ran for each user of a Mac.
- Open Terminal and run this command:
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
- Reboot your Mac device
If you need to re-enable the .DS_Store creation, run this command and reboot your Mac again:
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool false