# 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.

Source: https://www.jpkc.com/db/en/cheatsheets/macos/defaults/

<!-- PROSE:intro -->
`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.
<!-- PROSE:intro:end -->

## Read Preferences

`defaults read` — Show all user defaults for all domains.

```bash
defaults read
```

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

```bash
defaults read com.apple.finder
```

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

```bash
defaults read com.apple.dock autohide
```

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

```bash
defaults read-type com.apple.dock tilesize
```

`defaults domains` — List all preference domains.

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

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

```bash
defaults read NSGlobalDomain
```

## Write Preferences

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

```bash
defaults write com.apple.dock autohide -bool true
```

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

```bash
defaults write com.apple.dock tilesize -int 36
```

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

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

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

```bash
defaults write com.apple.screencapture type -string png
```

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

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

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

```bash
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
```

## Delete Preferences

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

```bash
defaults delete com.apple.dock autohide-delay
```

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

```bash
defaults delete com.apple.dock
```

## Finder Tweaks

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

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

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

```bash
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.

```bash
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.

```bash
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).

```bash
defaults write com.apple.finder FXDefaultSearchScope -string SCcf
```

## Dock Tweaks

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

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

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

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

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

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

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

```bash
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.

```bash
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).

```bash
defaults write com.apple.screencapture type -string png
```

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

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

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

```bash
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).

```bash
defaults write NSGlobalDomain KeyRepeat -int 2
```

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

```bash
defaults write NSGlobalDomain InitialKeyRepeat -int 15
```

`defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true` — Prevent .DS_Store files on network drives.

```bash
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
```

<!-- PROSE:outro -->
## 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)](https://ss64.com/mac/defaults.html) – compact reference of all options with examples
- [Property List Programming Guide (developer.apple.com)](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/PropertyLists/) – Apple's documentation of the plist format behind defaults
<!-- PROSE:outro:end -->

## Related Commands

- [caffeinate](https://www.jpkc.com/db/en/cheatsheets/macos/caffeinate/) – prevents the Mac from going to sleep
- [diskutil](https://www.jpkc.com/db/en/cheatsheets/macos/diskutil/) – manages disks, partitions and volumes
- [dscl](https://www.jpkc.com/db/en/cheatsheets/macos/dscl/) – browses and edits the directory service database

