How do I get Wi-Fi info from within Terminal?

Is there a way to get BSSID and the list of available Wi-Fi networks from within Terminal?

I.e. I'm looking for something similar to ifconfig run0 scan on OpenBSD, which lists all access points, BSSID, signal strength etc.


Solution 1:

There's an airport utility buried that you'll want to use. Create a symbolic link in /usr/local/bin to the utility for quick access with this command:

sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport

Now, you should be able to run airport -s and get a list of available networks with BSSIDs.

If you hold the option key while opening the WiFi networks in the Menu Bar, you can also see the BSSIDs one at a time, although it seems like you wanted the CLI-like version from OpenBSD.

UPDATE:

"rootless" AKA System Integrity Protection (SIP) has been added to OSX since I wrote this answer originally, which makes /usr/bin and /usr/sbin read-only. It is proper to use /usr/local/bin, so I have updated the answer so that the symbolic link is created there.