On a regular Linux, we would use this command to restart the computer:
1 |
sudo shutdown -r now |
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:
1 |
wsl --shutdown |
This stops our WSL instance. To get the same effect as a reboot, we can run wsl
again, this time without an additional parameter:
1 |
wsl |
To check that the reboot worked, we can ask for the uptime:
1 |
uptime -p |
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.