MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Thu, Mar 17, 2016 9:53 pm

Determine the currently connected Wi-Fi network from the command line on OS X

If you need to determine the currently connected WiFi network from a command line interface (CLI), aka a shell prompt, on an Apple OS X system, e.g., a MacBook Pro laptop, you can do so by opening a Terminal window (the application is in /Applications/Utilities) and issuing the command networksetup -getairportnetwork wifi_device where wifi_device is the port used for wireless connections on the system. You can determine the hardware port used for Wi-Fi connectivity on the system by issuing the command networksetup -listallhardwareports and then piping its output into the grep command looking for Wi-Fi in the output and when it is found displaying that line and the two lines after it. E.g., in the example below, en0 is the relevant device interface for wireless connections and the SSID for the currently connected Wi-Fi network is "Hogwarts".

$ networksetup -listallhardwareports | grep -A 1 "Wi-Fi"
Hardware Port: Wi-Fi
Device: en0
$ networksetup -getairportnetwork en0
Current Wi-Fi Network: Hogwarts

[/os/os-x] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo