Microsoft has announced that it has brought systemd support to WSL with the help of Canonical, the company behind Ubuntu. Due to some big changes that had to be made to WSL, Microsoft is making support opt-in for the time being, so existing WSL distros aren’t affected. After it gathers feedback, it’ll look at how to support systemd by default.
It was important for Microsoft to add systemd support to WSL because most popular Linux distribution use it by default. There are several Linux applications that depend on systemd including Canonical’s Snap, microk8s – which lets you get Kubernetes running locally, and systemctl – which is part of systemd and lets you interact with services.
Microsoft is rolling out the WSL update to Windows Insiders initially before bringing it to all users in a couple of weeks. If you’re not an Insider, you can still download the latest WSL release from GitHub. The version you need to be on to enable systemd is 0.67.6. With the latest WSL in place, you need to edit wsl.conf using the following command: sudo nano etc/wsl.conf, under [boot] make sure it reads systemd=true, close out of the nano editor using CTRL+O to save and CTRL+X to exit.
Now you need to restart your WSL instances, so run wsl.exe --shutdown from PowerShell. When you run a distro, you should be able to use systemctl list-unit-files --type=service to check systemd is running. To learn more about what you can do with systemd on WSL, check out this Canonical post that gives some ideas.