How to enable and disable systemd in Windows Subsystem for Linux (WSL)

Snap install on Ubuntu on WSL
(Image credit: Windows Central)

Until recently, the WSL community had been coming up with its own solutions to adding systemd support to their distros. Whatever your personal stance on systemd, for some processes it's a critical tool. Now, though, it's officially part of WSL

Eventually, it'll just be a thing that's there and you won't have to do much with it. But equally, you might not want it and need to know how to shut it off. 

Fortunately, the process to manually enable and disable systemd in WSL is simple and involves essentially the same steps.

What is systemd?

Officially, systemd is described as:

"Systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system."

On a simpler level, it's something you'll require if you want access to things such as snap packages on Ubuntu. In fact, Microsoft worked with Canonical to get systemd up and running in WSL. 

Many Linux distros use systemd when you run them on bare metal or in a virtual machine. The addition of it to WSL is another box ticked in making Microsoft's Linux-on-Windows experience closer to the real thing. 

System requirements

WSL version information

(Image credit: Windows Central)

To have access to systemd you will need to have WSL version 0.67.6 and above. If you're using the Microsoft Store version or have recently set up WSL on your machine, then you should already be on a supported build. 

To check which version of WSL you have installed, open up PowerShell and type: 

wsl --version

If you need to update to a supported version, you can do so from the same PowerShell window with the command: 

wsl --update

By default, you'll get the latest version from the Microsoft Store, but if you'd rather get it from GitHub you can add --web-download to the end of the command. The file is also available to download manually from the GitHub repo. 

Users of Ubuntu Preview on WSL should have systemd automatically available. 

How to enable and disable systemd in WSL

wsl.conf configuration file

(Image credit: Windows Central)

Having access to systemd is only the first part, to use it you have to enable it. There will likely be a time when it is already enabled by default as distro makers are now able to do this. 

But, if yours doesn't have it enabled, you'll need to turn it on. And if you don't want it you might want to know how to turn it off. All the magic is handled in the wsl.conf file, which is, as the extension suggests, a configuration file for your individual WSL distros. You will need to do this individually in all your different distros, currently, systemd cannot be enabled on a global basis. 

In your chosen Linux distro open the wsl.conf file with the following command: 

sudo nano /etc/wsl.conf

This will open the Nano text editor and unless you have already created a configuration file, it will be completely blank. To enable systemd you will need to add the following instructions: 

[boot]
systemd=true

If you're trying to disable it, you can set this to false or just remove the instruction entirely. Setting it to false does at least make it a little more convenient to re-enable in the future. 

From here, save the file and exit (using CTRL+O to save and CTRL+X to exit) and then close your Linux tab and return to PowerShell. To make sure systemd enables you will need to do a complete shutdown of WSL, wait at least eight seconds, then start it back up. Use this command to shutdown fully: 

wsl.exe --shutdown

After the eight second wait, open up your Linux distro again and systemd should now be enabled. The first boot may take a little longer, but when ready, you can check that systemd is working by entering this command: 

systemctl list-unit-files --type=service

Assuming all went to plan this will produce a complete list of all running services. If systemd hasn't been enabled, you will see an error message. You also need systemd enabled to carry out a number of tasks, even simpler ones, such as changing the host name on Fedora. 

One of the most obvious reasons to have systemd installed if you're using Ubuntu is to use snap to install packages. Once systemd is enabled, you can install packages, such as Nextcloud, by entering: 

sudo snap install nextcloud

If you want to know what's available through snap, you can browse the full library at snapcraft.io 

TOPICS
Richard Devine
Managing Editor - Tech, Reviews

Richard Devine is a Managing Editor at Windows Central with over a decade of experience. A former Project Manager and long-term tech addict, he joined Mobile Nations in 2011 and has been found on Android Central and iMore as well as Windows Central. Currently, you'll find him steering the site's coverage of all manner of PC hardware and reviews. Find him on Mastodon at mstdn.social/@richdevine