Flush DNS Cache

OS VersionCommand
macOS 12 (Monterey)sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS 11 (Big Sur)sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS 10.15 (Catalina)sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS 10.14 (Mojave)sudo killall -HUP mDNSResponder
macOS 10.13 (High Sierra)sudo killall -HUP mDNSResponder
macOS 10.12 (Sierra)sudo killall -HUP mDNSResponder
OS X 10.11 (El Capitan)sudo killall -HUP mDNSResponder
OS X 10.10 (Yosemite)sudo discoveryutil udnsflushcaches
OS X 10.9 (Mavericks)sudo killall -HUP mDNSResponder
OS X 10.8 (Mountain Lion)sudo killall -HUP mDNSResponder
Mac OS X 10.7 (Lion)sudo killall -HUP mDNSResponder
Mac OS X 10.6 (Snow Leopard)sudo dscacheutil -flushcache
Mac OS X 10.5 (Leopard)sudo lookupd -flushcache
Mac OS X 10.4 (Tiger)lookupd -flushcache
ipconfig /flushdns

Prevent creation of .DS_Store files on network shares

One thing that can be problematic when working with any shared storage is the existence of .DS_Store files on the network share, since these are intended for a single workstation’s use.

Enabling a policy to prevent the creation of .DS_Store files on network shares can speed up directory browsing (as described in this article) and prevent permission errors when moving/deleting files.

To prevent the Mac workstation from creating .DS_Store files on network shares, as well as instruct it to ignore existing .DS_Stores, open Terminal and enter:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE

and then log out/log in the macOS user account, or simply reboot the workstation.

To check the current policy in place, enter:

defaults read com.apple.desktopservices

If .DS_Store files are disallowed for network shares, “DSDontWriteNetworkStores = 1” should be displayed.

Note: To remove this policy and restore the default behavior, enter

defaults delete com.apple.desktopservices DSDontWriteNetworkStores

How to prevent the creation of .DS_Store files on network volumes

When working on network drives with Mac OS X every Mac user will by default create .DS_Store files. Those files are used by OS X to store custom attributes like icon positions. For more info on .DS_Store files read this article.

To prevent those files from being created:

  • Open up the Terminal
  • Run the following command
    defaults write com.apple.desktopservices DSDontWriteNetworkStores true
  • Restart your Mac or log out and back in.

Those .DS_Store files will now only be created on local volumes any you no longer have Windows users yelling at you about them. 😉