MacOS – Use defaults to edit preferences

defaultsmacospreferencesterminal

Recently, I have been playing around with editing System Preferences without GUI and using the defaults command. I have tried for example:

defaults write com.apple.dock autohide NO

Though that did not do anything. The preference was still checked in System Preferences, and the plist did not get edited when I opened it in Xcode. Even after relaunch of Finder and restart.

Am I using defaults properly? And if no, what is the proper use of it, when I am aiming to edit Preferences through terminal?


I am using OS X Mavericks (10.9.5)

Best Answer

Your command is adding a BOOL true or false.

So you needed to declare it as such by adding -bool. Otherwise you are changing to a string.

But also with this change you need to relaunch the dock for it to pick up the changes. You can do this by adding a second command.

killAll Dock

In one command:

defaults write com.apple.dock autohide  -bool no;killAll Dock 

This will run your command and kill any process named Dock. The Dock will then auto relaunch picking up the changes.