Sub topic 18
Changing Dock settings from Terminal
This chapter assumes you have used System Settings > Desktop & Dock and can open Terminal. You don't need shell scripting experience. Every command here changes only your own user account's preferences, and the last section shows how to undo them.
What the defaults command does
Most macOS apps store their settings in a preferences domain. A domain is a named bucket of key-value pairs, usually backed by a property list (plist) file in ~/Library/Preferences. The Dock's domain is com.apple.dock.
The defaults command reads, writes, and deletes keys in these domains. System Settings edits the same keys when you move a slider or flip a switch. Terminal gives you the same controls in a form you can type, save in a script, and repeat on another Mac.
Terminal also reaches a few options that System Settings hides. This chapter covers only the keys that appear in the Dock's own settings.
Read before you write
Start by reading a value. This command checks whether the Dock hides automatically:
defaults read com.apple.dock autohideIt prints 1 if auto-hide is on. If the key has never been set, it prints an error saying the domain/default pair does not exist. That error is not a fault. It means the Dock is using its built-in default, so nothing is stored.
You can also check which type a key holds:
defaults read-type com.apple.dock tilesizeReading a value before you change it lets you write the old value down, which makes a manual undo possible.
Write a setting and restart the Dock
A write needs three parts: the domain, the key, and a typed value. The type flag matters, because the Dock expects a specific type for each key.
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock tilesize -int 48
killall DockThe first line turns on auto-hiding. The second sets the icon size to 48 points. The third restarts the Dock so it re-reads its preferences.
killall Dock sounds drastic but is safe. The Dock is a background process, and macOS relaunches it automatically within a second or so. Your open apps and windows are not affected. The screen may flicker, and the Dock's animation state resets.
The diagram shows why the restart is needed. The write only changes the stored value. The running Dock does not notice until it starts again.
Common Dock keys
| Key | Type flag | Effect | Example value |
|---|---|---|---|
| `autohide` | `-bool` | Hides the Dock until the pointer reaches its edge | `true` |
| `tilesize` | `-int` | Icon size in points | `48` |
| `show-recents` | `-bool` | Shows or hides the recently used apps section | `false` |
| `orientation` | `-string` | Screen edge for the Dock | `left`, `bottom`, `right` |
Hide recent apps
The recents section sits at the right end of the Dock, after the divider. This turns it off:
defaults write com.apple.dock show-recents -bool false
killall DockMove the Dock
defaults write com.apple.dock orientation -string left
killall DockValid values are bottom, left, and right. A misspelled value does not produce an error from defaults. The command succeeds, and the Dock simply ignores the value or falls back to its default.
Common errors
- The change doesn't appear. You forgot
killall Dock. Run it and check again. - The wrong type was stored. Writing
autohidewith-string truestores text, not a boolean. Usedefaults read-typeto inspect it, then write the key again with the correct flag. - A typo in the key name.
defaults writecreates any key you give it. A misspelled key likeautohidis saved without complaint and does nothing. Read the key back to confirm the Dock is using it. - The domain is misspelled. Writing to
com.apple.doccreates a new, unrelated preferences file. The Dock never looks at it. - A managed Mac ignores the setting. If your organization manages the Mac with configuration profiles, those profiles can override the Dock's preferences.
Undo your changes
Deleting a key removes your override, so the Dock goes back to its built-in default for that key. This resets the four settings from this chapter:
defaults delete com.apple.dock autohide
defaults delete com.apple.dock tilesize
defaults delete com.apple.dock show-recents
defaults delete com.apple.dock orientation
killall DockIf a key was never set, defaults delete prints an error about a missing pair. You can ignore that error. The key is already at its default.
Deleting is cleaner than writing the default value back. After a delete, the plist holds no trace of your change, so System Settings and the Dock agree on what is set. System Settings should also show its original values after the restart.
When to use Terminal and when not to
Use System Settings for one-off adjustments. It validates values and applies them without a restart. Use defaults when you want to script a setup, apply the same settings to several Macs, or reach a key that System Settings does not show.
Keep in mind that a macOS update can change which keys exist or how the Dock treats them. A key that works today might do nothing later. Because deleting a key is always safe, an experiment costs you very little.
Exercise
You run defaults write com.apple.dock orientation -string left, but the Dock stays at the bottom of the screen. What did you most likely forget, and how do you return the Dock to its default position afterwards?
Show answer
You forgot to restart the Dock with killall Dock, so the running Dock never re-read its preferences. To return to the default, run defaults delete com.apple.dock orientation and then killall Dock.
Exercise
You typed defaults write com.apple.dock autohid -bool true and then killall Dock. The command printed no error, but the Dock doesn't hide. Why, and what should you do?
Show answer
The key name is misspelled (autohid instead of autohide). defaults write accepts any key name, so it saved an unused key. Delete the stray key with defaults delete com.apple.dock autohid, then run the write command with the correct key, autohide, and restart the Dock with killall Dock.