凤仙郡天下杂谈|Linux 终端中连接 WiFi?,如何在( 二 )


我觉得很奇怪 , 尽管有消息说更改不会在实例重启后保留 , 但它仍然可以工作 。
不管怎样 , 用这个命令生成配置:
sudonetplangenerate
现在应用它:
sudonetplanapply
如果你幸运的话 , 你应该连上网络 。 尝试ping一个网站或运行apt更新命令 。
然而 , 事情可能不会那么顺利 , 你可能会看到一些错误 。 如果是这种情况 , 请尝试一些额外的步骤 。
可能的故障排除
当你使用netplanapply命令时 , 你有可能在输出中看到类似这样的错误 。
Failedtostartnetplan-wpa-wlan0.service:Unitnetplan-wpa-wlan0.servicenotfound.Traceback(mostrecentcalllast):File''/usr/sbin/netplan'',line23,in<module>netplan.main()File''/usr/share/netplan/netplan/cli/core.py'',line50,inmainself.run_command()File''/usr/share/netplan/netplan/cli/utils.py'',line179,inrun_commandself.func()File''/usr/share/netplan/netplan/cli/commands/apply.py'',line46,inrunself.run_command()File''/usr/share/netplan/netplan/cli/utils.py'',line179,inrun_commandself.func()File''/usr/share/netplan/netplan/cli/commands/apply.py'',line173,incommand_applyutils.systemctl_networkd('start',sync=sync,extra_services=netplan_wpa)File''/usr/share/netplan/netplan/cli/utils.py'',line86,insystemctl_networkdsubprocess.check_call(command)File''/usr/lib/python3.8/subprocess.py'',line364,incheck_callraiseCalledProcessError(retcode,cmd)subprocess.CalledProcessError:Command'['systemctl','start','--no-block','systemd-networkd.service','netplan-wpa-wlan0.service']'returnednon-zeroexitstatus5.
可能是wpa_supplicant服务没有运行 。 运行这个命令:
sudosystemctlstartwpa_supplicant
再次运行netplanapply 。 如果它能解决这个问题 , 那就太好了 。 否则 , 使用下面的命令关闭Ubuntu系统[8]:
shutdownnow
重新启动Ubuntu系统 , 登录并再次生成和运行netplanapply:
sudonetplangeneratesudonetplanapply
现在可能会显示警告(而不是错误) 。 这是警告而不是错误 。 我检查了正在运行的systemd服务[9] , 发现netplan-wpa-wlan0.service已经在运行了 。 可能是因为它已经在运行了 , 而且netplanapply更新了配置文件(即使没有任何改变) , 所以显示了警告 。
Warning:Theunitfile,sourceconfigurationfileordrop-insofnetplan-wpa-wlan0.servicechangedondisk.Run'systemctldaemon-reload'toreloadunits.
这并不重要 , 你可以通过运行aptupdate来检查网络是否已经正常工作 。
我希望你能够在本教程的帮助下 , 在Ubuntu中使用命令行连接到WiFi 。 如果你仍然遇到困难 , 请在评论区告诉我 。
via:https://itsfoss.com/connect-wifi-terminal-ubuntu/
作者:AbhishekPrakash[10]选题:lujun9972[11]译者:geekpi[12]校对:wxy[13]
本文由LCTT[14]原创编译 , Linux中国[15]荣誉推出
【凤仙郡天下杂谈|Linux 终端中连接 WiFi?,如何在】[1]:https://itsfoss.com/what-is-desktop-environment/[2]:https://itsfoss.com/nextcloud/[3]:https://www.discourse.org/[4]:https://itsfoss.com/recommends/linode/[5]:https://itsfoss.com/install-ubuntu-server-raspberry-pi/[6]:https://netplan.io/[7]:https://itsfoss.com/nano-editor-guide/[8]:https://itsfoss.com/schedule-shutdown-ubuntu/[9]:https://linuxhandbook.com/systemd-list-services/[10]:https://itsfoss.com/author/abhishek/[11]:https://github.com/lujun9972[12]:https://github.com/geekpi[13]:https://github.com/wxy[14]:https://github.com/LCTT/TranslateProject[15]:https://linux.cn/article-12628-1.html?utm_source=rss&utm_medium=rss


推荐阅读