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 read

defaults read <domain> — Show all preferences for a specific app/domain.

defaults read com.apple.finder

defaults read <domain> <key> — Read a specific preference key.

defaults read com.apple.dock autohide

defaults read-type <domain> <key> — Show the data type of a preference key.

defaults read-type com.apple.dock tilesize

defaults domains — List all preference domains.

defaults domains | tr ',' '\n' | sort

defaults read NSGlobalDomain — Show global (system-wide) preferences.

defaults read NSGlobalDomain

Write Preferences

defaults write <domain> <key> -bool <true|false> — Set a boolean preference.

defaults write com.apple.dock autohide -bool true

defaults write <domain> <key> -int <value> — Set an integer preference.

defaults write com.apple.dock tilesize -int 36

defaults write <domain> <key> -float <value> — Set a float preference.

defaults write com.apple.dock autohide-delay -float 0.0

defaults write <domain> <key> -string '<value>' — Set a string preference.

defaults write com.apple.screencapture type -string png

defaults write <domain> <key> -array <val1> <val2> — Set an array preference.

defaults write com.apple.dock persistent-apps -array

defaults write NSGlobalDomain <key> <value> — Set a global (system-wide) preference.

defaults write NSGlobalDomain AppleShowAllExtensions -bool true

Delete Preferences

defaults delete <domain> <key> — Delete a specific preference key.

defaults delete com.apple.dock autohide-delay

defaults delete <domain> — Delete all preferences for a domain.

defaults delete com.apple.dock

Finder Tweaks

defaults write com.apple.finder AppleShowAllFiles -bool true — Show hidden files in Finder.

defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder

defaults write NSGlobalDomain AppleShowAllExtensions -bool true — Always show file extensions.

defaults write NSGlobalDomain AppleShowAllExtensions -bool true && killall Finder

defaults 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 Finder

defaults write com.apple.finder _FXShowPosixPathInTitle -bool true — Show full POSIX path in Finder title bar.

defaults write com.apple.finder _FXShowPosixPathInTitle -bool true && killall Finder

defaults write com.apple.finder FXDefaultSearchScope -string SCcf — Search the current folder by default (not entire Mac).

defaults write com.apple.finder FXDefaultSearchScope -string SCcf

Dock Tweaks

defaults write com.apple.dock autohide -bool true — Enable Dock auto-hide.

defaults write com.apple.dock autohide -bool true && killall Dock

defaults write com.apple.dock autohide-delay -float 0 — Remove Dock auto-hide delay.

defaults write com.apple.dock autohide-delay -float 0 && killall Dock

defaults write com.apple.dock tilesize -int <pixels> — Set the Dock icon size.

defaults write com.apple.dock tilesize -int 36 && killall Dock

defaults write com.apple.dock mineffect -string scale — Set minimize effect (genie, scale, suck).

defaults write com.apple.dock mineffect -string scale && killall Dock

defaults write com.apple.dock show-recents -bool false — Hide recent apps in the Dock.

defaults write com.apple.dock show-recents -bool false && killall Dock

System Tweaks

defaults write com.apple.screencapture type -string png — Set screenshot format (png, jpg, pdf, tiff, gif).

defaults write com.apple.screencapture type -string png

defaults write com.apple.screencapture location -string '<path>' — Set screenshot save location.

defaults write com.apple.screencapture location -string ~/Screenshots && killall SystemUIServer

defaults write com.apple.screencapture disable-shadow -bool true — Disable shadow in window screenshots.

defaults write com.apple.screencapture disable-shadow -bool true && killall SystemUIServer

defaults write NSGlobalDomain KeyRepeat -int 2 — Set key repeat rate (lower = faster, default 6).

defaults write NSGlobalDomain KeyRepeat -int 2

defaults write NSGlobalDomain InitialKeyRepeat -int 15 — Set delay until key repeat (lower = shorter, default 25).

defaults write NSGlobalDomain InitialKeyRepeat -int 15

defaults 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

  • caffeinate – prevents the Mac from going to sleep
  • diskutil – manages disks, partitions and volumes
  • dscl – browses and edits the directory service database