sudo killall coreaudiod made it so I don't have any sound at all

Solution 1:

This command will do it:

sudo launchctl stop com.apple.audio.coreaudiod && sudo launchctl start com.apple.audio.coreaudiod

Details

Martin Strouhal's answer doesn't work for OS X/macOS ≥ 10.12.4 due to removal of com.apple.audio.coreaudiod from system integrity protection's RemovableServices whitelist in /System/Library/Sandbox/com.apple.xpc.launchd.rootless.plist [1].

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist
/System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist: _
   Operation not permitted while System Integrity Protection is engaged

So instead of unloading the service, we instead just restart it.

Also, the latter command (sudo launchctl start com.apple.audio.coreaudiod) worked to restart the service after I had killed coreaudiod using killall coreaudiod.

Solution 2:

You need to reload coreaudiod instead of killing it. This one-liner will fix broken sound without restarting your mac

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist && sudo launchctl load /System/Library/LaunchDaemons/com.apple.audio.coreaudiod.plist