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).我需要删除一个保存的公共 wifi 网络,当我在家时,我的电脑一直试图连接到该网络,但由于我的 MacOS 安装错误,我无法打开我的网络首选项并通过 GUI 进行操作(有关详细信息,请参阅下面的链接问题)。

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?我猜可能有一种方法可以做到这一点,通过终端或挖掘 .plist,但无法通过搜索找到任何非 GUI 指南,那么这怎么能做到呢?

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)系统信息:MacBook Pro(视网膜,15 英寸,2015 年中) MacOS Sierra 10.12.6 (16G29)

                                   
Improve this question 改进此问题                                     
       

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):然后,您可以从列表中复制要删除的 wifi 的名称,并使用命令(替换wifi_to_be_removed为 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:【注】en0 通常是没有以太网端口的 Mac(现代便携式 Mac)中 AirPort Wifi 卡的设备名称。要确定设备名称,请使用以下命令:
sudo networksetup -listallhardwareports
 # to list the various network devices and their denomination. This would vary for# 列出各种网络设备及其名称。这将因以下原因而异

                                       
Improve this answer 改进此答案                                         
  • 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."有没有地方可以找到我的 wifi 卡的其他可能的设备名称?运行“-listpreferredwirelessnetworks en1”时,我收到错误“en1 不是 Wi-Fi 接口。** 错误:获取无线信息时出错。                                        
    – ssssaaaa ssssaaaa                                         
     CommentedFeb 20, 2018 at 9:38 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 ssssaaaa                                         
     CommentedFeb 20, 2018 at 9:47 Feb 20, 2018 at 9:47                                     
  • 1                                    
    sudo networksetup -listallhardwareports                                         
  • #gives you the list of the devices#为您提供设备列表                                        
    – Gio Valerio 吉奥·瓦莱里奥                                         
     CommentedFeb 20, 2018 at 15:17 Feb 20, 2018 at 15:17                                     
  • 1                                    
    updated the answer 更新了答案  
    – Gio Valerio 吉奥·瓦莱里奥                                         
     CommentedFeb 20, 2018 at 18:50 Feb 20, 2018 在 18:50                                     
  • 1                                    
    could also be  也可能是 en0                                        , that's the case on a 2019 MBP at least. but yes,,至少在 2019 年的 MBP 上是这样。但是,是的,-listallhardwareportsshows that too, after I got在我得到en1 is not a Wi-Fi interface.                                        . .  
    – Italian Philosophers 4 Monica 意大利哲学家 4 莫妮卡                                         
     CommentedOct 3, 2022 at 1:49 Oct 3, 2022 at 1:49                                      

You must log in             to answer this question.您必须登录才能回答此问题。