How to Restart WSL Without Rebooting Your Computer
On a regular Linux, we would use this command to restart the computer:
When we try that in WSL (Windows Subsystem for Linux), we end up with this error message:
System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down Failed to talk to init daemon: Host is down
To restart WSL without restarting our whole computer, we need to exit WSL with the exit command and then run wsl with the shutdown option:
This stops our WSL instance. To get the same effect as a reboot, we can run wsl again, this time without an additional parameter:
To check that the reboot worked, we can ask for the uptime:
up 0 minutes
This little option is especially useful when you upgrade the Linux distribution inside WSL, and you are at the last step that requires a reboot.