Ubuntu is unable to shutdown in Windows Subsystem for Linux

14,293

Solution 1

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 '.*'
    

Solution 2

If you do want to restart the entire computer, try the following command from the Ubuntu shell:

cmd.exe /C shutdown /r /t 30 /c "The subsystem wants to restart"

or to shutdown entirely:

cmd.exe /C shutdown /s /t 30

Check out this page to read more about Windows-Subsystem interoperability: https://docs.microsoft.com/en-us/windows/wsl/interop

Solution 3

I you want to just exit the Windows Subsystem for Linux, you can use command logout, exit or keyboard shortcut Ctrl+D.

Share:
14,293

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    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