Can't restart/shutdown Ubuntu under WSL
I know this is old but just found that you can do it through powershell
list distributions:
wsl --list
will output something like
Windows Subsystem for Linux Distributions:
Ubuntu (Default)
docker-desktop-data
docker-desktop
terminate Ubuntu
wsl --terminate Ubuntu
or terminate all
wsl --shutdown
hope this helps!
Sometimes wsl --shutdown
doesn't seem to work, like running these commands:
wsl --shutdown
wsl -l -v
result in some containers still running:
NAME STATE VERSION
* docker-desktop-data Stopped 2
docker-desktop Stopped 2
Ubuntu-20.04 Running 2
Turns out the WSL instances are automatically started when you try to access the WSL drives. In my case, \\wsl$\Ubuntu-20.04\workspace
was open in an IDE, and it caused the instance to restart immediately after shutdown. After I closed the IDE I was able to properly shut down WSL.
EDIT:
It is actually a very nice feature, I don't have to manually start WSL, I just open my IDE and it finds the drive it needs.