本文结合了知乎上的文章以及文章里的一条评论
出现的问题
reboot
$ reboot
System has not been booted with systemd as init system (PID 1). Can’t operate.
Failed to connect to bus: Host is down.
runlevel
$ runlevel
unknown
init
$ init 3
Couldn't find an alternative telinit implementation to spawn
解决步骤
步骤1~4
步骤5
1.创建文件/etc/wsl.conf
并编辑
$ touch /etc/wsl.conf
$ vim /etc/wsl.conf
将以下内容粘贴进去👇
[boot]
systemd=true
2.重启WSL
打开Windows PowerShell,输入以下内容后按回车键
wsl --shutdown
结果
再次打开终端就可以使用reboot runlevel init
啦
其实还有一个问题
执行reboot
和init
命令必需使用root权限,但目前觉得无伤大雅,就先不管了