Change default alert sound from terminal in Mac OSX

Solution 1:

It looks like for macOS Sierra you simply need to change the Alert Sound under the Sound System Preferences (System Preferences > Sound > Sound Effects).

Solution 2:

In Sierra:

defaults write .GlobalPreferences com.apple.sound.beep.sound /System/Library/Sounds/Submarine.aiff

Solution 3:

I don't know how to make Terminal use a different alert sound, but if others search for how to change the OS X-wide alert sound from a script, change the com.apple.sound.beep.sound key in the com.apple.systemsound domain:

defaults write com.apple.systemsound com.apple.sound.beep.sound /System/Library/Sounds/Frog.aiff