A .DS_Store file is a hidden folder created automatically by macOS on every directory you open in Finder
The file name stands for "Desktop Services Store". macOS creates one in each folder to remember how you arranged that folder's window — the size, position, icon view settings, and which files you had selected. You will not see it in Finder by default because macOS hides files that start with a dot, but the file is there on your Mac and on any external drives or network folders you browse.
These files are small, usually between 4 and 16 kilobytes, and they exist only on macOS. Windows and Linux systems ignore them. The problem arises when you share folders with other people or sync them across devices — the .DS_Store files get copied along, they clutter shared directories, and they can cause merge conflicts in version control systems like Git.
Key Takeaways
- .DS_Store files are created by macOS in every folder you open and store window layout preferences, not personal data or system settings.
- These files are hidden by default in Finder but still exist and get copied when you share folders, back up drives, or push code to repositories.
- You can view hidden files in Finder using Cmd+Shift+Period, or delete .DS_Store files individually or in bulk from the command line.
- Preventing new .DS_Store files from being created on external drives requires a Terminal command, but they will still appear on your internal Mac drive.
Why macOS creates .DS_Store files in every folder
When you open a folder in Finder and resize the window, change the view to list or icon mode, or sort by name or date, macOS saves those choices. The next time you open that same folder, it looks exactly as you left it. That information lives in the .DS_Store file.
This happens automatically and silently. You do not choose to create these files — macOS does it for you. The system creates a new .DS_Store file the first time you open any folder in Finder, whether it is a folder on your Mac, an external hard drive, a USB stick, or a network share. If you have never opened a folder in Finder, no .DS_Store file exists for it yet.
Where .DS_Store files appear and why they spread
Every folder on your Mac that you have opened in Finder contains a .DS_Store file. This includes your Desktop folder, Downloads, Documents, and any subfolder inside them. If you plug in an external drive and browse its contents, macOS creates .DS_Store files on that drive too — even if the drive is formatted for Windows or shared with other computers.
The files spread when you back up your Mac, sync folders to cloud storage, or push code to a Git repository. A developer who clones a project from GitHub might find .DS_Store files mixed in with the actual source code. A designer who shares a folder of images with a colleague on Windows will send .DS_Store files along with the images, and those files serve no purpose on the Windows machine.
This is why many projects include a .gitignore file that tells Git to ignore .DS_Store files — the developers do not want these macOS-specific files cluttering the repository history.
How to view hidden .DS_Store files in Finder
By default, Finder hides all files and folders that start with a dot. To see them, press Cmd+Shift+Period (the period key, not the full stop on the number pad). Finder will show all hidden files and folders, including .DS_Store files, system files, and configuration folders like .git and .ssh.
Press the same key combination again to hide them. This toggle works in any Finder window and persists until you toggle it off — Finder will keep showing hidden files in all windows until you change the setting.
On older versions of macOS, you can also open Terminal and run defaults write com.apple.finder AppleShowAllFiles true, then restart Finder by pressing Cmd+Option+Esc and selecting Finder, then clicking Relaunch. This method is less convenient than the keyboard shortcut.
Deleting .DS_Store files from your Mac
You can delete .DS_Store files manually by viewing them in Finder and dragging them to Trash, but this is tedious if you have many folders. A faster approach is to use Terminal.
Open Terminal (found in Applications > Utilities) and run this command to delete all .DS_Store files on your Mac:
find ~ -name ".DS_Store" -delete
This searches your entire home directory and deletes every .DS_Store file it finds. The process takes a few seconds depending on how many folders you have. After deletion, macOS will create new .DS_Store files the next time you open folders in Finder, so this is a one-time cleanup rather than a permanent solution.
To delete .DS_Store files from an external drive, plug in the drive and run the same command but replace the tilde (~) with the path to the drive. For example, if your external drive is named "Backup", the command would be:
find /Volumes/Backup -name ".DS_Store" -delete
Preventing .DS_Store files on external drives
You can prevent macOS from creating new .DS_Store files on external drives and network shares by running this Terminal command:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
After running this command, macOS will no longer create .DS_Store files when you browse external drives or network folders. The setting applies to all external media going forward. You do not need to restart your Mac for this to take effect.
This command does not prevent .DS_Store files from being created on your internal Mac drive — those will continue to appear in your home folder and its subfolders. If you want to disable .DS_Store creation everywhere, including on your Mac itself, that requires a different approach and is not recommended because some macOS features rely on these files.
Why you should not delete .DS_Store files from shared or synced folders
If you are working on a team and share folders through Dropbox, Google Drive, OneDrive, or a network server, deleting .DS_Store files can cause unnecessary sync conflicts. Every time someone on a Mac opens a folder, a new .DS_Store file is created, and the sync service flags it as a change. This creates clutter in your sync history and can confuse version control.
The better approach is to add .DS_Store to your .gitignore file if you use Git, or to configure your cloud storage to ignore these files. Most modern development tools and cloud services already do this automatically.
Frequently Asked Questions
Is .DS_Store a virus or security risk?
.DS_Store files are not malicious and pose no security risk. They contain only information about how you arranged a folder window — nothing about your files, passwords, or personal data. They are a normal part of how macOS works.
Will .DS_Store files cause problems on Windows or Linux?
No. Windows and Linux systems simply ignore .DS_Store files. They will not affect how those systems work, though the files will take up a small amount of storage space if they are copied to a Windows or Linux machine.
Do I need to delete .DS_Store files regularly?
No. Deleting them is optional and mainly useful if you are sharing folders with others or pushing code to a repository. On your personal Mac, they cause no harm and use negligible storage space. Most people never need to think about them.
Why does my external drive have .DS_Store files if I have never opened it on a Mac?
If the drive was previously connected to any Mac and browsed in Finder, .DS_Store files were created then. Even if you only looked at the drive's contents once, macOS created these files automatically.
Can I prevent .DS_Store files from appearing in cloud backups?
Most cloud backup services and sync tools like Backblaze, Carbonite, and Dropbox have built-in filters that exclude .DS_Store files automatically. Check your service's settings to confirm, but most modern tools handle this without requiring manual configuration.