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 /norestartRestart your computer, set WSL 2 as default and install Ubuntu:
wsl --set-default-version 2 wsl --install -d UbuntuLaunch WSL, set up your account when prompted & update packages:
sudo apt update && sudo apt upgrade -yEnable systemd:
Edit /etc/wsl.conf:
sudo nano /etc/wsl.confAdd:
[boot] systemd=trueRestart WSL:
exit wsl --shutdown wslVerify systemd is running:
ps --no-headers -o comm 1This should output “systemd”