defaults is the macOS command for reading, writing and deleting user and system preferences stored in property list domains, making it one of the core tools of Terminal & scripting on the Mac. Each application and many system components keep their settings as key-value pairs inside a preference domain, and defaults gives direct command-line access to those values, including many that have no switch in the graphical interface.
The phrase defaults write is often used as a synonym, because writing a value is the most common reason people run the tool. Administrators use it to configure Macs consistently by script, and power users use it to enable hidden behaviors in the Finder, the Dock and other built-in apps.
How the preferences system works
macOS stores preferences in property list files, typically under ~/Library/Preferences for the current user and /Library/Preferences for all users. Applications do not read these files directly; they ask the cfprefsd daemon, which caches values in memory and writes them back to disk at its own pace.
This caching is the reason why editing a plist file by hand is unreliable: cfprefsd may overwrite the change with its cached copy. The defaults command talks to cfprefsd through the same Core Foundation preferences API that applications use, so its changes are seen consistently.
The table below lists the main preference scopes that the command can address.
| Scope | Example domain or flag | Typical file location |
|---|---|---|
| Application domain | com.apple.finder | ~/Library/Preferences/com.apple.finder.plist |
| Global domain | NSGlobalDomain or -g | ~/Library/Preferences/.GlobalPreferences.plist |
| Current host only | -currentHost flag | ~/Library/Preferences/ByHost/ |
| System-wide domain | /Library/Preferences/... with sudo | /Library/Preferences/ |
| Sandboxed app domain | Bundle identifier | ~/Library/Containers/<id>/Data/Library/Preferences/ |
Core subcommands and value types
The command follows the pattern defaults [scope] verb domain key [type value]. A small set of verbs covers nearly every administrative task, and explicit type flags prevent a value from being stored with the wrong data type.
| Verb | Purpose | Example |
|---|---|---|
| read | Show one key or a whole domain | defaults read com.apple.dock autohide |
| write | Create or change a value | defaults write com.apple.dock autohide -bool true |
| delete | Remove a key or a domain | defaults delete com.apple.dock autohide |
| read-type | Report the stored data type | defaults read-type com.apple.dock tilesize |
| domains | List all known domains | defaults domains |
| find | Search keys and values by word | defaults find autohide |
| export / import | Save or load a whole domain | defaults export com.apple.dock dock.plist |
Values are typed. Writing true without -bool stores the string “true”, which many applications ignore, so always specifying the type is the decisive habit for reliable results.
| Flag | Stored type | Typical use |
|---|---|---|
-bool | Boolean | Feature switches |
-int | Integer | Sizes, counts, delays in steps |
-float | Floating-point number | Animation durations, scales |
-string | String | Paths, identifiers, modes |
-array and -array-add | Ordered list | Lists of items or paths |
-dict and -dict-add | Dictionary | Nested key-value settings |
Making a change take effect
Writing a value does not guarantee that a running application notices it. Most apps read preferences at launch, so the change appears only after the app is quit and reopened, or, for system components, after restarting the process with killall, for example killall Dock or killall Finder.
Some settings are read only at login, so a logout or restart is required. Changing preferences of a running app can also be undone when that app writes its in-memory state back on quit, which is why quitting the target app first is the safest order.
Sandboxed applications add another subtlety. Their preferences live inside the app container, and on recent macOS versions access to another app’s container may trigger a privacy prompt or require Full Disk Access for Terminal. Addressing the domain by its bundle identifier rather than by a file path lets cfprefsd locate the correct container automatically and avoids writing to a stale copy outside it. Reading a domain with defaults read before and after a change in System Settings is also the most practical way to discover which key controls a setting, because Apple documents only a fraction of them.
Comparison with related configuration tools
The command is one of several ways to configure a Mac, and choosing correctly depends on scale, persistence and enforcement. It changes values once; it does not stop a user from changing them back.
| Method | Scope | Enforced | Best suited for |
|---|---|---|---|
| defaults command | One user or one Mac | No | Quick tweaks and setup scripts |
| PlistBuddy | One plist file | No | Editing nested structures in files |
| System Settings | One user | No | Everyday changes by end users |
| Configuration profile | Managed Macs | Yes | Fleet policies through MDM |
| AppleScript or osascript | Running apps | No | Settings exposed through scripting |
In organizations, configuration profiles delivered by MDM take priority over values written with this tool: a managed key shows the enforced value, and local writes have no effect on it. The command remains useful for testing a key before building a profile.
Risks and good practice
The tool performs no validation of keys or values, so a typo silently creates an unused key and a wrong type can make an application misbehave. Undocumented keys may also change or disappear between macOS releases, which makes long-lived tweaks fragile.
- Back up first: run
defaults exporton the domain before a significant change. - Specify the type: always add
-bool,-intor another type flag. - Quit the app: close the target application before writing to its domain.
- Use delete to revert: deleting a key restores the application default.
- Avoid sudo for user settings: writing with sudo targets root preferences, not the user.
A non-technical view
Every app on a Mac keeps a small list of settings, such as which folder opens first or how big the Dock icons are. Most of these settings have buttons in the app. Some do not.
The defaults command is a way to open that list and change entries by typing. It is like adjusting a thermostat with the service panel instead of the front dial. You get access to more options, but a wrong entry is not caught for you. Saving a copy first is the sensible step.
A concrete example
An IT technician at a design studio prepares 25 new Macs for staff. Every designer wants the same setup: file extensions always visible, the full path shown in the Finder title bar, and screenshots saved to a dedicated folder instead of the desktop.
The technician writes a short zsh script with three commands: defaults write NSGlobalDomain AppleShowAllExtensions -bool true, defaults write com.apple.finder _FXShowPosixPathInTitle -bool true and defaults write com.apple.screencapture location -string ~/Pictures/Screenshots, followed by killall Finder and killall SystemUIServer. Each Mac takes under a minute instead of about ten minutes of clicking through settings, and every machine ends up configured identically. Because staff may still adjust these preferences, the studio later moves the screenshot policy into an MDM profile.