defaults — Read and Write macOS Preferences
Read and write macOS user defaults — application settings, hidden system preferences and configuration values stored in property list (plist) files.
defaults is the macOS built-in command for reading and writing preferences straight from the terminal – the very same values that apps and the system otherwise keep in their property list (plist) files. Every setting belongs to a domain (such as com.apple.dock or com.apple.finder) and consists of a key holding a typed value. The real payoff: defaults also exposes many "hidden" tweaks that have no switch in System Settings. This guide walks you through the key commands, from reading and writing values to the popular Finder, Dock and system tweaks.
Read Preferences
defaults read — Show all user defaults for all domains.
defaults readdefaults read <domain> — Show all preferences for a specific app/domain.
defaults read com.apple.finderdefaults read <domain> <key> — Read a specific preference key.
defaults read com.apple.dock autohidedefaults read-type <domain> <key> — Show the data type of a preference key.
defaults read-type com.apple.dock tilesizedefaults domains — List all preference domains.
defaults domains | tr ',' '\n' | sortdefaults read NSGlobalDomain — Show global (system-wide) preferences.
defaults read NSGlobalDomainWrite Preferences
defaults write <domain> <key> -bool <true|false> — Set a boolean preference.
defaults write com.apple.dock autohide -bool truedefaults write <domain> <key> -int <value> — Set an integer preference.
defaults write com.apple.dock tilesize -int 36defaults write <domain> <key> -float <value> — Set a float preference.
defaults write com.apple.dock autohide-delay -float 0.0defaults write <domain> <key> -string '<value>' — Set a string preference.
defaults write com.apple.screencapture type -string pngdefaults write <domain> <key> -array <val1> <val2> — Set an array preference.
defaults write com.apple.dock persistent-apps -arraydefaults write NSGlobalDomain <key> <value> — Set a global (system-wide) preference.
defaults write NSGlobalDomain AppleShowAllExtensions -bool trueDelete Preferences
defaults delete <domain> <key> — Delete a specific preference key.
defaults delete com.apple.dock autohide-delaydefaults delete <domain> — Delete all preferences for a domain.
defaults delete com.apple.dockFinder Tweaks
defaults write com.apple.finder AppleShowAllFiles -bool true — Show hidden files in Finder.
defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finderdefaults write NSGlobalDomain AppleShowAllExtensions -bool true — Always show file extensions.
defaults write NSGlobalDomain AppleShowAllExtensions -bool true && killall Finderdefaults write com.apple.finder ShowPathbar -bool true — Show the path bar at the bottom of Finder.
defaults write com.apple.finder ShowPathbar -bool true && killall Finderdefaults write com.apple.finder _FXShowPosixPathInTitle -bool true — Show full POSIX path in Finder title bar.
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true && killall Finderdefaults write com.apple.finder FXDefaultSearchScope -string SCcf — Search the current folder by default (not entire Mac).
defaults write com.apple.finder FXDefaultSearchScope -string SCcfDock Tweaks
defaults write com.apple.dock autohide -bool true — Enable Dock auto-hide.
defaults write com.apple.dock autohide -bool true && killall Dockdefaults write com.apple.dock autohide-delay -float 0 — Remove Dock auto-hide delay.
defaults write com.apple.dock autohide-delay -float 0 && killall Dockdefaults write com.apple.dock tilesize -int <pixels> — Set the Dock icon size.
defaults write com.apple.dock tilesize -int 36 && killall Dockdefaults write com.apple.dock mineffect -string scale — Set minimize effect (genie, scale, suck).
defaults write com.apple.dock mineffect -string scale && killall Dockdefaults write com.apple.dock show-recents -bool false — Hide recent apps in the Dock.
defaults write com.apple.dock show-recents -bool false && killall DockSystem Tweaks
defaults write com.apple.screencapture type -string png — Set screenshot format (png, jpg, pdf, tiff, gif).
defaults write com.apple.screencapture type -string pngdefaults write com.apple.screencapture location -string '<path>' — Set screenshot save location.
defaults write com.apple.screencapture location -string ~/Screenshots && killall SystemUIServerdefaults write com.apple.screencapture disable-shadow -bool true — Disable shadow in window screenshots.
defaults write com.apple.screencapture disable-shadow -bool true && killall SystemUIServerdefaults write NSGlobalDomain KeyRepeat -int 2 — Set key repeat rate (lower = faster, default 6).
defaults write NSGlobalDomain KeyRepeat -int 2defaults write NSGlobalDomain InitialKeyRepeat -int 15 — Set delay until key repeat (lower = shorter, default 25).
defaults write NSGlobalDomain InitialKeyRepeat -int 15defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true — Prevent .DS_Store files on network drives.
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true Conclusion
defaults is your key to macOS settings that no preference pane exposes – perfect for setting up new Macs reproducibly or baking tweaks into a setup script. Keep two things in mind: defaults writes directly into your system preferences, and many changes only take effect once you restart the affected app – usually with killall Dock, killall Finder or killall SystemUIServer. When in doubt, read a value first with defaults read before overwriting it, and watch the domain and type: a wrong domain or data type can confuse apps or leave the setting with no effect.
Further Reading
- defaults – macOS man page (ss64.com) – compact reference of all options with examples
- Property List Programming Guide (developer.apple.com) – Apple's documentation of the plist format behind defaults
Related Commands
- caffeinate – prevents the Mac from going to sleep
- diskutil – manages disks, partitions and volumes
- dscl – browses and edits the directory service database