Ubuntu – Ubuntu is unable to shutdown in Windows Subsystem for Linux

bashshutdownwindows-subsystem-for-linux

I am running the Ubuntu shell for Windows 10 as a part of a module in university, when I try typing in shutdown, it is telling me

System has not been booted with systemd as init system (PID 1). 

Can't operate, this is the same when I type in reboot and using sudo in front of the command

Best Answer

If you want to shutdown the entire computer, apparently Windows has decided it doesn't want to let Ubuntu do that.

If you want to just restart Ubuntu, then from this question on superuser Rebooting Ubuntu on Windows without rebooting Windows? you could:

  • Using CMD (Administrator)

      net stop LxssManager
      net start LxssManager
    
  • Or Using services applet

    1. WIN+R -> services.msc
    2. Find LxssManager

      enter image description here

    3. Right-click -> Restart

  • Since Windows 10 version 1803, closing all WSL terminal windows won't kill background processes by default, unless the file /var/run/reboot-required is present. This file will be automatically created by apt on Ubuntu when an update requires a reboot, but if you want to manually reboot the subsystem, you can create the file yourself:

       sudo touch /var/run/reboot-required
    

    I haven't tested this on other distributions available in the Microsoft Store. An alternative solution is to kill all processes yourself:

       sudo killall -r '.*'
    
Related Question