Since Ubuntu 22.04 it is possible to use systemd in an experimental state on WSL installations. This guide explains how you can easily set it up in just a few steps.
Setup Guide
- Install
wsl-setup
package, if its not already there.
sudo apt install wsl-setup
- Create a
/etc/wsl.conf
file (WSL Configuration Documentation):
For WSL comes with Windows 10/11:
[boot]
command="/usr/libexec/wsl-systemd"
For WSL Preview from MS Store in Windows 11:
[boot]
systemd=true
- Create
/run/users/1000
and set user rights (optional: but was needed for snapd):
sudo mkdir -p /run/users/1000
sudo chown $USER:$GROUP /run/users/1000
- Relaunch wsl with following command from windows or set as launch option in your terminal:
wsl -e /usr/libexec/nslogin /bin/bash