See All Previously Used Defaults Commands in Mac OS X

Jan 31, 2012 - 8 Comments

defaults history

It’s easy to lose track of all the defaults commands used to perform tweaks to Mac OS X, but with the help of the history command it’s easy to list every defaults write and accompanying defaults delete commands ever used on a Mac. Launch the Terminal to get started.

See All Defaults Commands Executed

To see all defaults commands, including defaults write, defaults read, defaults delete, and even those requiring sudo:

history |grep "defaults"

Will return something like this:

47 sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
48 sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo IPaddress
98 defaults write com.apple.DiskUtility DUDebugMenuEnabled 1
206 defaults write com.apple.Safari IncludeInternalDebugMenu 1
237 defaults write com.apple.dock itunes-notifications -bool TRUE;killall Dock
238 defaults delete com.apple.dock itunes-notifications
239 defaults write com.apple.dock desktop-picture-show-debug-text -bool TRUE;
241 defaults delete com.apple.dock desktop-picture-show-debug-text;killall Dock

See Only Defaults Write Commands

To see only defaults write commands, including those requiring sudo:

history |grep "defaults write"

The results will look the same as above, but without showing any defaults read or defaults delete commands.

See Only Defaults Delete Commands

To see which defaults write commands have been reverted, grep for ‘delete’ rather than ‘write’:

history |grep "defaults delete"

See Defaults Commands Related to Specific App

By changing the text within grep to an application or process name, we can see which defaults commands were used only for that specific application. For example, to see only defaults commands that impacted the Finder:

history |grep "defaults write com.apple.finder"

Most apps are easy to find this way, and the default applications in OS X almost always follow the ‘com.apple.appname’ convention.

We touched on this concept before in a past post about the history command, but focusing on defaults commands is useful enough to deserve individual recognition.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, Mac OS X, Tips & Tricks

8 Comments

» Comments RSS Feed

  1. Mike says:

    Good idea.

    Also, add this to .bash_profile and you can actively log commands containing defaults commands.

    PROMPT_COMMAND=’echo “$(history 1 | grep “defaults”)” | sed ‘/^$/d’ >> ~/Documents/defaults.txt’

    Same idea but just adding each executed command to a text file for easy recall. Adjust the path and filename as necessary.

  2. markux says:

    Ctrl+r and type defaults, if you retypre ctrl+r you find next occurrence and ctrl+alt+r prev occurrence

  3. [...] Applications for Mac Users Two of the most common applications for a Mac user is to keep track of defaults entries that have been entered into the Terminal and to quickly find past commands. Query command history [...]

  4. Ado says:

    How to clear this history???

  5. [...] most frequently used commands, dumping history and searching it to find specific past commands, listing all defaults commands used, or whatever else. That said, there are some obvious situations where you may want to remove that [...]

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates