Can I used the command line to disable settings in Yosemite that have made my Mac visible?

Recent changes to my machine as the result of an upgrade to Yosemite (OS X 10.10) have made my machine visible on Bluetooth and Bonjour, where it was not visible before.

Is there a command line way to disable/enable the relevant features so that my machine can be restored to "invisibility" to these services (e.g. when I'm in a less secure environment)?


Bonjour

Prior, to Yosemite this could be done via launchctl, so using:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

would turn Bonjour off, and to turn it back on:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

Unfortunately /usr/sbin/mDNSResponder is not found on Yosemite.

A bit of digging and this seems to work for Bonjour:

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.discoveryd.plist

NB: I'm not clear if this means it stays off, it should given launchctl behaviour but I've have not had time to test it and determine if anything else in the system will turn it back on.

Bluetooth

Presuming you're talking about your Mac's built-in bluetooth and not a third party adaptor, then:

networksetup -listallnetworkservices

Lists all services, usually show Bluetooth as 'Bluetooth DUN'

killall blued

Kills the bluetooth server process

Launchctl commands

launchctl unload /System/Library/LaunchDaemons/com.apple.blued.plist

Unload the bt daemon

launchctl load /System/Library/LaunchDaemons/com.apple.blued.plist

Reload the bt daemon

launchctl start com.apple.blued

Restart blued daemon


As mentioned by notacouch, cppl's answer doesn't work on Yosemite as killall blued doesn't find the process.

As recommended on notacouch shared URL's you need to do this: Open the Terminal utility

Run the following two commands:

sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport;
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport

When done, if Bluetooth is off then turn it back on and choose your devices from the Bluetooth menu. As a quick tip, you can select both of the commands above and then drag the selection to a Finder window, to create a text clipping of them in a convenient location (such as your Desktop). You can then quickly run the commands by dragging the clipping to a new Terminal window.

For more details follow this URL