Ubuntu 无法在适用于 Linux 的 Windows 子系统中关闭

vik*_*ing 5 bash shutdown windows-subsystem-for-linux

我正在运行 Windows 10 的 Ubuntu shell 作为大学模块的一部分,当我尝试输入关闭时,它告诉我

System has not been booted with systemd as init system (PID 1). 
Run Code Online (Sandbox Code Playgroud)

不能操作,这个和我在命令前面输入reboot并使用sudo时一样

Xen*_*050 5

如果你想关闭整个计算机,显然 Windows 已经决定不让 Ubuntu 这样做。

如果您只想重新启动 Ubuntu,那么可以从超级用户在 Windows 上重新启动 Ubuntu 而不重新启动 Windows 的问题开始?你可以:

  • 使用CMD(管理员)

      net stop LxssManager
      net start LxssManager
    
    Run Code Online (Sandbox Code Playgroud)
  • 或者使用服务小程序

    1. WIN+R->services.msc
    2. 寻找LxssManager

      在此输入图像描述

    3. 右键单击->Restart

  • 自 Windows 10 版本 1803 起,默认情况下关闭所有 WSL 终端窗口不会终止后台进程,除非该文件/var/run/reboot-required存在。当更新需要重新启动时,该文件将由 Ubuntu 上的 apt 自动创建,但如果您想手动重新启动子系统,您可以自己创建该文件:

       sudo touch /var/run/reboot-required
    
    Run Code Online (Sandbox Code Playgroud)

    我尚未在 Microsoft Store 中提供的其他发行版上对此进行测试。另一种解决方案是自行终止所有进程:

       sudo killall -r '.*'
    
    Run Code Online (Sandbox Code Playgroud)