5

I need to delete a saved public wifi network, which my computer keeps trying to connect to when I'm at home, but I can't open my Network preferences and do it trough the GUI, due to an error in my MacOS installation (see linked question below for details).

I'm guessing there might be a way to do it, through Terminal or digging into a .plist, but haven't been able to find any non-GUI guides to this through searching, so how can this be done?

Why does my Network preference pane freeze every time I open it?

System info: MacBook Pro (Retina, 15-inch, Mid 2015) MacOS Sierra 10.12.6 (16G29)

1 Answer 1

10

You can check the list of preferred networks with the command:

sudo networksetup -listpreferredwirelessnetworks en0

You can then copy the name of the wifi you want to remove from the list and use the command (replacing wifi_to_be_removed with the name of the wifi):

sudo networksetup -removepreferredwirelessnetwork en0 wifi_to_be_removed

Note: en0 is usually the device name of the AirPort Wifi card in a mac that doesn't have an ethernet port (modern portable Macs). To be sure of the device name use the command:
sudo networksetup -listallhardwareports
to list the various network devices and their denomination. This would vary for

6
  • Is there a place I can find other possible device names for my wifi card? When running `-listpreferredwirelessnetworks en1´ I get the error "en1 is not a Wi-Fi interface. ** Error: Error obtaining wireless information."
    – ssssaaaa
    Commented Feb 20, 2018 at 9:38
  • Just realised I hadn't added my device specs to this post, so have done that now, hopefully that helps.
    – ssssaaaa
    Commented Feb 20, 2018 at 9:47
  • 1
    sudo networksetup -listallhardwareports gives you the list of the devices Commented Feb 20, 2018 at 15:17
  • 1
    updated the answer Commented Feb 20, 2018 at 18:50
  • 1
    could also be en0, that's the case on a 2019 MBP at least. but yes, -listallhardwareports shows that too, after I got en1 is not a Wi-Fi interface.. Commented Oct 3, 2022 at 1:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .