To stop .DS_Store files from appearing on a Mac network share, you must disable their creation on your Mac and clean up existing ones. This article explains how to prevent macOS from writing these files to network volumes, how to remove them, and why they appear in the first place.
What Are .DS_Store Files?
.DS_Store (Desktop Services Store) is a hidden file macOS creates in every folder you open in Finder. It stores custom view settings—icon positions, window size, sort order, background color—so the folder looks the same when you revisit it. The file is invisible in Finder but appears when you browse a network share from another computer (Windows, Linux, or another Mac with hidden files shown).
On a local disk these files are harmless. On a network share, however, they clutter listings, confuse users, and can cause permission errors when multiple people access the same folder. They are especially annoying on SMB shares used by mixed-OS environments.
Why Do .DS_Store Files Appear on Network Drives?
macOS writes a .DS_Store file to any folder you open in Finder, including folders on mounted network volumes. This behavior is by design—macOS assumes every folder is local. Even if you never intentionally create files, simply browsing the share triggers the creation of .DS_Store in each directory you visit.
On a Mac, the file is hidden, so you don’t notice it. But when you access the same share from a Windows PC, Linux machine, or a NAS web interface, the hidden attribute is not respected, and the files show up as regular entries. Over time, a busy share accumulates hundreds of these files.
How to Stop Creating .DS_Store Files on Network Volumes
macOS does not offer a built-in checkbox to disable .DS_Store creation. However, you can achieve the same effect by running a command that sets a global preference. This command works on macOS Catalina (10.15) and later, including current versions like Sonoma and Sequoia.
- Open Terminal (Applications → Utilities → Terminal).
- Type the following command and press Return:
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true - Restart your Mac (or at least log out and back in) for the change to take effect.
After this, macOS will not create .DS_Store files on network volumes. It will still create them on local folders, which is normal and harmless.
To revert the change later, replace true with false in the same command.
How to Remove Existing .DS_Store Files from a Network Share
Disabling future creation does not delete files that are already there. To clean up a network share, you can use Terminal to find and delete all .DS_Store files recursively. Be careful to run this only on the network share, not on your local disk.
- Mount the network share in Finder.
- Open Terminal and navigate to the share. For example:
cd /Volumes/ShareName - Run the following command to delete all .DS_Store files in the share and its subfolders:
find . -name ".DS_Store" -type f -delete
This command permanently deletes those files. It does not affect any other data. If you want to see what would be deleted first, replace -delete with -print to list them.
If you prefer a graphical tool, some third-party apps like CleanMyMac or BlueHarvest can do this, but the Terminal command is free and built-in.
What About Windows and Linux Users?
If you are a Windows or Linux user seeing .DS_Store files on a network share, you cannot change how macOS creates them. You can, however, hide them from your view:
- Windows: In File Explorer, go to View → Options → Change folder and search options → View tab, then check “Don’t show hidden files, folders, or drives.� This hides files with the hidden attribute, but .DS_Store files are not always marked hidden. Alternatively, you can use a file manager like Directory Opus that lets you filter out specific names.
- Linux: In Nautilus or other file managers, enable “Show Hidden Files� (Ctrl+H) to toggle visibility. To hide them permanently, you can create a script that deletes them periodically, or use a mount option like
nohiddenif your system supports it.
The cleanest solution is to ask the Mac user to run the defaults write command above.
Common Problems and Misconceptions
“I ran the command but .DS_Store files still appear.� The command only affects network volumes. If you are testing on a local folder, it will still create them. Also, you must restart Finder or your Mac for the change to take effect. Some users report that the command works only after a reboot, not just a logout.
“The command didn’t work on older macOS.� The DSDontWriteNetworkStores key has existed since macOS 10.4 Tiger. It works on all versions, but on some older systems (pre-Catalina) the exact command might be slightly different—though the same key is used. For macOS 10.15 and later, the command above is correct.
“Deleting .DS_Store files will break something.� No. These files only store view settings. If you delete them, macOS will recreate them on the next visit to that folder (unless you disabled creation). You might lose custom folder views, but no data is lost.
“I can just set the folder to read-only.� That prevents macOS from writing .DS_Store, but it also prevents you from saving any files to that folder, which is usually not acceptable.
Alternatives for Network Admins
If you manage a network share used by many Macs, you cannot run the defaults command on every client. Instead, you can:
- Set the share to be read-only for most users, and give write access only to a specific folder.
- Use a NAS that automatically filters hidden files (some Synology and QNAP devices have this option).
- Schedule a cron job on the server to delete .DS_Store files every night.
- Educate Mac users to run the
defaultscommand themselves—it takes 30 seconds.
For SMB shares on macOS Server, there is no built-in setting to block .DS_Store creation globally; the client-side command is the only reliable method.
Frequently Asked Questions
Q: Will the defaults write command affect my local folders?
A: No. It only stops creation on network volumes. Local folders will still get .DS_Store files, which is fine because they are hidden and harmless.
Q: Do I need to restart my Mac after running the command?
A: Yes, a full restart is recommended. Some users find that logging out and back in works, but a reboot guarantees the change is applied.
Q: Can I delete .DS_Store files on a network share without Terminal?
A: Yes, you can use Finder if you enable hidden files (press Cmd+Shift+. in macOS). Then you can manually delete them, but that is tedious for many folders. Terminal is the efficient way.
Q: Why do .DS_Store files appear on a USB drive connected to a Mac?
A: A USB drive is not a network volume, so the defaults write command does not affect it. To stop creation on external drives, you can use the same command but with DSDontWriteUSBStores instead of DSDontWriteNetworkStores (this key works on macOS 10.13+).
Q: Is it safe to delete .DS_Store files on a server?
A: Yes, it is safe. They are not needed for the folder to function. The only downside is that folder view settings are lost, and they may be recreated if a Mac user visits the folder again.
Q: What if I don’t have admin rights on my Mac?
A: The defaults write command writes to your user preferences, so it should work without admin rights. If it fails, contact your IT department to apply the setting for you.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Mac Start Up Automatically After Power Failure?
- Expose Self-Hosted Service Securely Without Cloudflare Tunnel
- Nano Delivery for Functional Foods: What It Can and Can’t Do4.00
- Disable Apple Watch Turn-by-Turn Vibration While Driving
- Convert Play FLAC in iTunes: Full Guide
- Soda Foundation Charter: What It Means