Deleting entries in defaults

defaults

I have accidentally added an entry to my defaults (/usr/bin/defaults) that is preventing me from installing apps via iTunes. How do I undo my change?

This is the command to read the offending entry:

/usr/bin/defaults read /Library/Preferences/com.apple.usbmuxd

Which gives the following result:

{
    BlackList =     (
        "com.apple.iTunes"
    );
}

It was added by

/usr/bin/defaults write /Library/Preferences/com.apple.usbmuxd BlackList -array-add com.apple.iTunes

I thought this would remove it, but I can't figure it out.

/usr/bin/defaults delete /Library/Preferences/com.apple.usbmuxd BlackList com.apple.iTunes

This just returns the help for defaults

Here are a few more things I've tried and the results

/usr/bin/defaults delete /Library/Preferences/com.apple.usbmuxd BlackList
Domain (/Library/Preferences/com.apple.usbmuxd) not found.

/usr/bin/defaults delete /Library/Preferences/com.apple.usbmuxd com.apple.iTunes
Domain (/Library/Preferences/com.apple.usbmuxd) not found.

Not sure what the "Domain not found" error is. I tried sudo as well and saw the same error message. Is that not the domain I just added to with the initial write step?

I think this is the command in defaults I want to use:

delete <domain> <key>                deletes key in domain

Best Answer

You can delete the BlackList array with

defaults delete /Library/Preferences/com.apple.usbmuxd BlackList
#        delete <domain>                               <key>

Apple doesn't provide an easy way to remove an array element. You can either set the BlackList array with -array with the item excluded, or edit the file manually using Xcode for example.