This is my personal collection of command line tricks on Mac OS X that I found indispensable. The list is far from complete, and may be added to in the future.
Show hidden files in Finder
> defaults write com.apple.finder AppleShowAllFiles true
> killall Finder
The first line sets the preference for the Finder to show hidden files, while the second line restarts the Finder so the setting comes in effect. As an alternative for the last line, select the Finder in the Cmd-Alt-Escape popup and select “Relaunch”. I found this one on the Mozilla knowledge base .
Delete all .DS_Store files
> sudo find / -name ".DS_Store" -print -delete
If hidden files are enabled in the finder, you will soon make contact with the infamous “.DS_Store” files that the desktop service litters around as you browse the filesystem. This is annoying. Use the above command to delete those suckers. The “-print” is in there just so you can monitor the progress.
Prevent .DS_Store files on network mounts
> defaults write com.apple.desktopservices DSDontWriteNetworkStores true
Although there is no method to generally stop “.DS_Store” files, at least you can prevent desktop services from polluting network mounts. Windows users on the same network will be glad! This trick is published in the Apple knowledge base .
Disable Spotlight indexing for a given volume
> sudo mdutil -i off /mountpoint
This command will disable indexing for the volume under /mountpoint (for instance /Volumes/MyExternalHarddisk). Under MacOS X 10.5 and later, it also deletes any partial index created up to this point. There is one caveat: The enable/disable information is itself stored inside the “.Spotlight-V100” directory, so do not delete that, and be careful when backing up to another drive. More information is found in .
 The X-Lab, “Spotlight tips”,
 MozillaZine, “Show hidden files and folders”,
 Apple Support, “Mac OS X v10.4 and later: How to prevent .DS_Store file creation over network connections”,