Systemd is Available on WSL

Windows Subsystem for Linux (WSL) can now run systemd inside our installed WSL distributions. This is old news, announced September 2022, but I only found out about this today! I might need to update some of my WSL blog posts. In my opinion this is a nice feature release that allows us to do more with our Windows Linux machines. Below is some (hopefully) useful information on what this means.

What is Systemd?

systemd is a system and service manager for Linux. Its primary component is the init system used to bootstrap user space and manage user processes.

Here are some key points about systemd:
1. Unified Configuration: systemd unifies service configuration and behavior across various Linux distros.
2. Parallel Boot: It offers reliable parallelism during boot, improving system startup time.
3. Service Management: systemd replaces various daemons and utilities, including device management, login management, network connection management, and event logging.

The screenshot below is an example of using systemctl to list all services on a WSL Ubuntu distro.

# check system services wsl ubuntu
systemctl list-unit-files --type=service
Systemctl List Services

How to Enable Systemd on WSL

Systemd was originally released in WSL Version 0.67.6, Sep 21, 2022 (WSL Git Version history). On an up to date system you should be able to run systemd commands without needing to make any changes to enable it. For my fully up to date Windows 11 system running WSL version, I did not need to make any changes.

If you try the systemctl service command example above in this post and it fails, you should first ensure your computer is updated. Install Windows Updates, and run wsl --version to check your current WSL version after. Make sure WSL Version higher than 0.67.6 and refer to the WSL Latest Releases.

If it’s still not working we can add a line to the /etc/wsl.conf within the WSL distro.

Amend \etc\wsl.conf
# check wsl config file contents
cat /etc/wsl.conf

# amend wsl config file
vi /etc/wsl.conf

Once the above steps are done, you may need to reboot WSL for systemd to be enabled.

For more information on using systemd in WSL, check out the Microsoft Docs on using systemd to manage Linux services with WSL.

Leave a Reply

Your email address will not be published. Required fields are marked *