Defaults (software)
Encyclopedia
defaults is a command line utility that manipulates plist
Property list
In the Mac OS X, iOS, NeXTSTEP, and GNUstep programming frameworks, property list files are files that store serialized objects. Property list files use the filename extension .plist, and thus are often referred to as p-list files....

 files. defaults is present in the Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

 and GNUstep
GNUstep
GNUstep is a free software implementation of Cocoa Objective-C libraries , widget toolkit, and application development tools not only for Unix-like operating systems, but also for Microsoft Windows. It is part of the GNU Project.GNUstep features a cross-platform, object-oriented development...

 operating systems, and it first appeared in the NeXTStep
NEXTSTEP
NeXTSTEP was the object-oriented, multitasking operating system developed by NeXT Computer to run on its range of proprietary workstation computers, such as the NeXTcube...

 operating system upon which both of the aforementioned systems are based. The system stores each user's preferences set in a .plist file for each program stored at ~
Home directory
A Home directory is a file system directory on a multi-user operating system containing files for a given user of the system. The specifics of the home directory is defined by the operating system involved; for example, Windows systems between 2000 and 2003 keep home directories in a folder...

/Library/Preferences for user-specific preferences, and /
Root directory
In computer file systems, the root directory is the first or top-most directory in a hierarchy. It can be likened to the root of a tree — the starting point where all branches originate.-Metaphor:...

Library/Preferences/ for global preferences. Either way, the defaults utility writes or reads from these plist files depending on the one given.

Usage

The most common uses of defaults is:

$ defaults read $PLIST_FILE # gets all
$ defaults read $PLIST_FILE $PROPERTY_NAME # gets
$ defaults write $PLIST_FILE $PROPERTY_NAME $VALUE # sets
$ defaults delete $PLIST_FILE $PROPERTY_NAME # resets a property
$ defaults delete $PLIST_FILE # resets preferences

$PLIST_FILE is replaced by the plist file, without the extension. plist files are named similar to Java package
Java package
A Java package is a mechanism for organizing Java classes into namespaces similar to the modules of Modula. Java packages can be stored in compressed files called JAR files, allowing classes to download faster as a group rather than one at a time...

s: you take the software developer's domain name
Domain name
A domain name is an identification string that defines a realm of administrative autonomy, authority, or control in the Internet. Domain names are formed by the rules and procedures of the Domain Name System ....

, reverse it, place a dot (.), and then the application's name followed by .plist. So for example, iTunes
ITunes
iTunes is a media player computer program, used for playing, downloading, and organizing digital music and video files on desktop computers. It can also manage contents on iPod, iPhone, iPod Touch and iPad....

' plist file would be com.apple.iTunes.plist. When you pass the value to defaults, you remove the .plist:

$ defaults read com.apple.iTunes # prints all of iTunes' preference values

plist files store property lists and values. The $PROPERTY_NAME value becomes the name of the property to modify. For example, to remove the Search field from Safari
Safari
A safari is an overland journey, usually a trip by tourists to Africa. Traditionally, the term is used for a big-game hunt, but today the term often refers to a trip taken not for the purposes of hunting, but to observe and photograph animals and other wildlife.-Etymology:Entering the English...

's address bar:

$ defaults write com.apple.Safari AddressBarIncludesGoogle 0

or

$ defaults write com.apple.Safari AddressBarIncludesGoogle -boolean FALSE # case-sensitive!

Replacing 0 with 1 or FALSE with TRUE returns the search bar to normal.

Sometimes, preferences cause corrupt applications. To reset Address Book's preferences, you would either remove ~/Library/Preferences/com.apple.AddressBook or issue the command

$ defaults delete com.apple.AddressBook
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK