Prevent creation of .DS_Store files in network shares

If you run your Mac in a mixed network environment you’ll surely have noticed .DS_Store files appearing in the shared folders of your Linux or Windows boxes, they’re hidden files used to store custom attributes of a folder such as the position of icons or the choice of a background image.
By default, MacOS X will create a .DS_Store file in every folder it accesses, while this is ok in OS X it may be annoying for network shares. To prevent the creation of .DS_Store files on network volumes execute this from a Terminal:

defaults write DSDontWriteNetworkStores true

In addition, to easily get rid of all already existing .DS_Store execute from a Terminal:

sudo find / -name '\.DS_Store' -print -delete

Note: In MacOS X 10.5 (Leopard) .DS_Store files are now set invisible for the Windows filesystem so if you don’t run any other OSes you may not need this