Ads 468x60px

Get a List of Preferred Wi-Fi Networks from the Command Line

Retrieving a list of preferred wireless networks can be helpful when troubleshooting wi-fi problems. The following trick will do just that, and it's similar to a tip we covered recently which showed how to see a list of previously connected wi-fi networks using either System Preferences or a lengthy command line string, but as far as the command line goes the following command is much shorter and cleaner, and doesn't require the use of sed and regex to clean up the output. Though similar, it's important to note there may be some differences in the output of the commands too, as this trick provides a list specifically of the preferred networks, whereas the aforementioned article discussed retrieving networks that the Mac has simply connected to, whether they are preferred or not. Which information is going to be the most useful to you will likely vary on your use case.

For a MacBook Air with only a Wi-Fi NIC, the command would be as follows:

networksetup -listpreferredwirelessnetworks en0

Meanwhile, iMacs, Mac Mini's, Mac Pro's, and some MacBook Pro's with dual Wi-Fi and Ethernet capabilities might use the following instead:

networksetup -listpreferredwirelessnetworks en1

The command is the same, the only difference is the interface used at the end of the command (en0 vs en1), which is sometimes different on different Macs, particularly those with wifi and ethernet capabilities.

For those who are less comfortable with the Terminal and want a simpler GUI approach, the aforementioned article's Network Preferences method remains less technical.

This nice little tip comes as a commenter response on MacWorld to coverage of our original method.