Get a List of Preferred Wi-Fi Networks from Command Line on Mac
Retrieving a list of preferred wireless networks can be helpful when troubleshooting wi-fi problems, amongst other reasons too. If you’re looking to print out a list of wi-fi networks the Mac has used as preferred and connected to before, the following trick will do just that!
This is similar to another tip we covered 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.
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.
How to View a List of Preferred Wi-Fi Networks on Mac via Terminal
For a MacBook Air, MacBook Pro, and MacBook with only a Wi-Fi NIC, the command would be as follows:
networksetup -listpreferredwirelessnetworks en0
Meanwhile, iMacs, older Mac Mini’s, Mac Pro’s, and some other 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.