defaults is a
command line
A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
utility that manipulates
plist files. Introduced in 1998
OPENSTEP
OpenStep is a defunct object-oriented application programming interface (API) specification for a legacy object-oriented operating system, with the basic goal of offering a NeXTSTEP-like environment on non-NeXTSTEP operating systems. OpenStep wa ...
, ''defaults'' is found in the system's descendants
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
and
GNUstep
GNUstep is a free software implementation of the Cocoa (formerly OpenStep) Objective-C frameworks, widget toolkit, and application development tools for Unix-like operating systems and Microsoft Windows. It is part of the GNU Project.
GNUst ...
.
The name "defaults" derives from OpenStep's name for
user preferences, ''Defaults'', or ''NSUserDefaults'' in
Foundation Kit
The Foundation Kit, or just Foundation for short, is an Objective-C framework in the OpenStep specification. It provides basic classes such as wrapper classes and data structure classes. This framework uses the prefix NS (for NeXTSTEP). It is ...
. Each application had its own defaults plist ("domain"), under for the user configuration and for the system configuration. The lookup system also supports a , where defaults written there will be seen by all applications.
In macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
, the part of the path is replaced by the more intuitive . ''defaults'' accesses the plists based on the domain given.[
''defaults'' is also able to read and write any plist specified with a path,][ although Apple plans to phase out this utility in a future version.][
]
Usage
Common uses of defaults:
$ defaults read DOMAIN # gets all
$ defaults read DOMAIN PROPERTY_NAME # gets
$ defaults write DOMAIN PROPERTY_NAME VALUE # sets
$ defaults delete DOMAIN PROPERTY_NAME # resets a property
$ defaults delete DOMAIN # resets preferences
DOMAIN should be replaced by the plist file name sans extension ('.plist'). plist files are named with reverse domain name notation. For example:
$ defaults read com.apple.iTunes # prints all iTunes preference values
plist files store keys and values. The PROPERTY_NAME key is the name of the property to modify. For example, to remove the search field from Safari
A safari (; ) is an overland journey to observe wild animals, especially in eastern or southern Africa. The so-called "Big Five" game animals of Africa – lion, leopard, rhinoceros, elephant, and Cape buffalo – particularly form an importa ...
's address bar
In a web browser, the address bar (also location bar or URL bar) is the element that shows the current URL. The user can type a URL into it to navigate to a chosen website. In most modern browsers, non-URLs are automatically sent to a search eng ...
:
$ defaults write com.apple.Safari AddressBarIncludesGoogle 0
$ # or
$ defaults write com.apple.Safari AddressBarIncludesGoogle -bool NO # case-sensitive!
Using "1", "YES", or "TRUE" instead restores this to the default of including search.
Preferences can at times corrupt applications. To reset Address Book's preferences, either the file ~/Library/Preferences/com.apple.AddressBook.plist must be removed or the following command issued:
$ defaults delete com.apple.AddressBook
Compound values
''defaults'' prints values in the OpenStep format. It allows the VALUE to be arrays and dicts, as long as they conform to old-style plist syntax.
Settings
Some example settings configurable with defaults under macOS:
SS64 documents a set of other keys that can be changed for each software (not the global domain) in macOS. Other sites also document settings to be changed using ''defaults''. Apple does not publish a complete list of these "secret knobs", but their support site does occasionally provide ''defaults'' commands for user to change a certain setting, such as the creation of .DS_Store
In the Apple macOS operating system, .DS_Store is a file that stores custom attributes of its containing folder, such as folder view options, icon positions, and other visual information. The name is an abbreviation of ''Desktop Services Store' ...
.[ (type into a search engine to find more: site:support.apple.com "defaults write")]
GNUstep documents its defaults more clearly, so that there is no such thing as a "hidden settings" community like there is for macOS.
References
{{Reflist
NSUserDefaults documentation
Apple Inc
MacOS software
GNUstep
Command-line software