Stop .DS_Store File Creation on Network Connections
In this article
- What Are .DS_Store Files?
- Why Does macOS Create .DS_Store on Network Drives?
- How to Disable .DS_Store Creation on Network Volumes
- How to Remove Existing .DS_Store Files from Network Drives
- Alternative Methods and Third-Party Tools
- Common Problems and Misconceptions
- Does This Affect macOS Updates or Security?
- Frequently Asked Questions
To stop macOS from creating .DS_Store files on network connections, you must disable the creation of these files for network volumes using the defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true command in Terminal. This setting prevents Finder from writing .DS_Store files to any network-mounted volume, though it does not affect local drives. Below, we explain what .DS_Store files are, why they appear, how to apply the fix, and how to clean up existing files.
What Are .DS_Store Files?
.DS_Store (short for Desktop Services Store) is a hidden file that macOS creates in every folder you open in Finder. It stores custom view options for that folder—such as icon size, window position, background color, and sort order—so that the folder appears the same way each time you revisit it. The file is invisible by default in Finder, but it becomes visible when you browse a network share from another operating system or use the ls -a command in Terminal.
On a local drive, .DS_Store files are harmless and rarely noticed. However, on network volumes (like SMB shares, NFS mounts, or AFP servers), these files can clutter shared directories, confuse Windows or Linux users, and sometimes cause permission errors or version-control noise. For these reasons, many system administrators and power users prefer to disable their creation on network connections.
Why Does macOS Create .DS_Store on Network Drives?
When you open a folder on a network share, Finder treats it like any other folder and automatically creates a .DS_Store file to store view preferences. This behavior is intentional—it allows the same folder to remember how you like to view it, even across reboots. However, because network shares are often accessed by multiple users and different operating systems, these hidden files can accumulate quickly and become a nuisance.
For example, if you connect to a Windows file server, every folder you browse gets a .DS_Store file that Windows users see as a hidden file (if they have “show hidden files” enabled). Over time, these files can number in the thousands, consuming inodes on the server and making directory listings messy. In shared development environments, .DS_Store files may also be accidentally committed to Git repositories, causing merge conflicts and clutter.
How to Disable .DS_Store Creation on Network Volumes
The official method to stop .DS_Store creation on network connections is a single Terminal command. Here are the steps:
- Open Terminal (found in /Applications/Utilities/).
- Type the following command and press Enter:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - Restart Finder by typing
killall Finderand pressing Enter, or simply log out and back in.
After this, macOS will no longer create .DS_Store files on any network volume. Note that this setting only affects network volumes, not your local hard drive or external drives. If you want to re-enable creation later, replace true with false in the same command.
This setting works on all modern versions of macOS, including Ventura, Sonoma, and Sequoia. It is a standard user default that Apple has supported for years, though it is not exposed in System Settings.
How to Remove Existing .DS_Store Files from Network Drives
Disabling creation does not delete files that already exist. To clean up existing .DS_Store files on a network share, you can use Finder’s search or Terminal. The safest way is to use Terminal with a find command:
- Mount the network volume you want to clean.
- Open Terminal and type:
find /Volumes/YourVolumeName -name ".DS_Store" -delete
ReplaceYourVolumeNamewith the actual name of the mounted volume. - Press Enter. This will delete all .DS_Store files on that volume.
Be careful: this command permanently deletes the files, and you will lose any custom view settings for those folders. Also, make sure you have write permissions on the network share, or the command may fail with permission errors. If you prefer a graphical method, you can use Finder’s search (Command+F), select “File name” and type “.DS_Store”, then delete the results—but this is slower for large shares.
Alternative Methods and Third-Party Tools
While the defaults command is the only built-in method, some users prefer third-party utilities like BlueHarvest or CleanMyMac to manage .DS_Store files. These tools offer a GUI and can also clean up other junk files. However, they are not necessary for the basic fix, and they often require a paid license. For most users, the Terminal command is sufficient and free.
Another alternative is to avoid using Finder for network browsing and instead use command-line tools like scp or rsync, which do not create .DS_Store files. This is common for developers who work with remote servers, but it is not practical for everyday file management.
Common Problems and Misconceptions
One common misconception is that the DSDontWriteNetworkStores setting also affects USB drives or external hard drives. It does not—it only applies to network volumes. If you want to disable .DS_Store on external drives, you would need a third-party tool or a more complex configuration.
Another issue is that the setting may not take effect immediately. If you run the command but do not restart Finder, the old behavior may persist until you do. Also, some network protocols (like WebDAV) may still create the file if the server itself generates it, but that is rare.
Finally, note that .DS_Store files are not the same as .localized files, which store folder name translations. Do not confuse the two when cleaning up.
Does This Affect macOS Updates or Security?
Disabling .DS_Store creation on network volumes is a safe, reversible change. It does not affect system security, nor does it prevent macOS from functioning normally. The only downside is that you lose per-folder view preferences on network shares, but this is a minor trade-off for a cleaner shared environment.
macOS updates will not reset this setting, as it is stored in the user’s preferences. However, if you ever create a new user account on the same Mac, you will need to apply the command again for that account, as the setting is per-user.
Frequently Asked Questions
Will this stop .DS_Store files on my external USB drive?
No, the DSDontWriteNetworkStores setting only affects network volumes. External drives are treated as local storage, and Finder will still create .DS_Store files on them. To disable on external drives, you would need a third-party tool or a more advanced configuration.
Do I need to restart my Mac after running the command?
No, a full restart is not required. Restarting Finder with killall Finder is enough, as Finder is the process that creates these files. Logging out and back in also works.
Will this delete existing .DS_Store files?
No, the command only prevents new files from being created. To delete existing files, you must use the find command or manually delete them.
Does this work on all macOS versions?
Yes, the defaults write command has been supported for many years and works on all current macOS versions, including Ventura, Sonoma, and Sequoia. It is a standard preference key that Apple has not deprecated.
Can I re-enable .DS_Store creation later?
Yes, simply run the command with -bool false instead of true, and then restart Finder. This restores the default behavior.