How to Configure systemd in WSL 2 on Windows 11 Using PowerShell

Historically, Windows Subsystem for Linux (WSL 2) initialized Linux distributions using a custom Microsoft init process rather than standard systemd. While lightweight, this architecture prevented developers from running essential background daemons, microservices, and management tools—such as systemctl, Docker daemon, MicroK8s, and Apache—without cumbersome wrapper scripts. Modern WSL 2 releases include native systemd support. Enabling systemd via PowerShell unlocks standard Linux service architecture inside Windows 11.

Prerequisites for systemd Support

Ensure your Windows 11 environment meets the following specifications:

  • Windows 11 version 21H2 or newer.
  • WSL version 0.67.6 or later (verify by running wsl --version in PowerShell).
  • A modern Linux distribution installed from the Microsoft Store (such as Ubuntu 22.04 LTS, Debian, or openSUSE).

Configuring systemd in wsl.conf via PowerShell

You can inject the required systemd directive into your Linux distribution directly from an elevated PowerShell terminal:

# Specify target distribution name
$distro = "Ubuntu"

# Construct wsl.conf payload enabling systemd
$wslConf = @"
[boot]
systemd=true
"@

# Write configuration file directly into Linux /etc/wsl.conf
wsl -d $distro -u root -- bash -c "echo '$wslConf' > /etc/wsl.conf"

Write-Host "Configured systemd=true in /etc/wsl.conf for $distro" -ForegroundColor Green

This automated command writes the [boot] section into the distribution’s configuration file with root privileges.

Restarting WSL to Initialize systemd

To launch Linux under PID 1 systemd execution, perform a clean shutdown from PowerShell:

  1. Terminate active WSL sessions:
    wsl --shutdown
  2. Relaunch your Linux distribution:
    wsl -d Ubuntu
  3. Verify that systemd is operating as process ID 1:
    ps -p 1 -o comm=
  4. The shell returns systemd. You can now use standard service commands:
    systemctl list-units --type=service

Enabling Auto-Starting Services

With systemd active, services like SSH and cron launch automatically upon distribution startup:

sudo systemctl enable --now cron

Enabling native systemd in WSL 2 bridges the gap between Windows desktop workflows and standard Linux server production environments.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.