Run Linux programs in Windows
Setting Up WSL with Systemd
Windows Subsystem for Linux (WSL) allows you to run a Linux environment directly on Windows without the need for a virtual machine. This guide will walk you through the process of setting up WSL and enabling systemd.
Enabling systemd in WSL2 provides a more complete Linux environment, closer to a traditional Linux system. It allows for better service management, improved compatibility with certain applications, and enables features like systemctl commands. This setup is particularly useful for developers who need a more robust Linux environment within Windows.
Enable WSL and Virtual Machine Platform: In PowerShell (Admin):
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your computer, set WSL 2 as default and install Ubuntu:
wsl --set-default-version 2 wsl --install -d Ubuntu
Launch WSL, set up your account when prompted & update packages:
sudo apt update && sudo apt upgrade -y
Enable systemd:
Edit /etc/wsl.conf:
sudo nano /etc/wsl.conf
Add:
[boot] systemd=true
Restart WSL:
exit wsl --shutdown wsl
Verify systemd is running:
ps --no-headers -o comm 1
This should output “systemd”