Celeb Glow
updates | February 26, 2026

How to enable systemd on WSL2: Ubuntu 20 and CentOS 8

I'm on WSL2 (Windows Subsystem for Linux, v2) and got the CentOS 8 WSL from:

And the Ubuntu 20 WSL downloaded from Windows Store has no systemd enabled too.

Got it run as usual, however, systemd is not running, although it does exist in the file system:

$ cat /etc/*-release | grep NAME
NAME="CentOS Linux"
PRETTY_NAME="CentOS Linux 8 (Core)"
CPE_NAME="cpe:/o:centos:centos:8"
$ stat /lib/systemd/systemd File: /lib/systemd/systemd Size: 2523648 Blocks: 4936 IO Block: 4096 regular file
Device: 2h/2d Inode: 1407374884100769 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-05-31 13:17:53.497597100 +0700
Modify: 2020-04-10 04:52:32.000000000 +0700
Change: 2020-05-30 12:06:52.791586300 +0700 Birth: -
$ systemctl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

/sbin/init is already a symbolic link to systemd:

$ stat /sbin/init File: /sbin/init -> ../lib/systemd/systemd Size: 22 Blocks: 0 IO Block: 4096 symbolic link
Device: 2h/2d Inode: 2251799814381086 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2020-04-10 04:52:20.000000000 +0700
Modify: 2020-04-10 04:52:20.000000000 +0700
Change: 2020-05-30 12:06:53.461589000 +0700 Birth: -

I found 2 init files:

/init
/sbin/init --> /lib/systemd/systemd

Possibly WSL2 Linux kernel loads /init instead of /sbin/init?

How to enable systemd in this distro, for daemons like sshd, nginx, etc. to run? Need to touch /sbin/init or that kind of file?

3 Answers

I have a work-around here but it doesn't work for those services explicitly require systemd:

Still using /init instead of /sbin/init on WSL2, works for regular services, not those explicitly require 'systemd'.

Find out where systemctl is:

which systemctl

Use the path to systemctl for the following commands.

Install Python 2 (if not available by default):

sudo dnf install python2 -y
sudo ln -s /usr/bin/python2 /usr/bin/python

Wrap systemctl in Python (or somehow let systemctl work with systemd not on PID 1):

sudo mv /usr/bin/systemctl /usr/bin/systemctl.old
curl >temp
sudo mv temp /usr/bin/systemctl
sudo chmod +x /usr/bin/systemctl

Test systemctl:

sudo dnf install nginx -y
sudo systemctl start nginx
curl localhost
sudo systemctl stop nginx

The systemd-genie is recommended for every distro supported and endorsed by systemd.io. It works both in the system (systemd --system) and user mode (systemd --user). t is well maintained and easy for integration with wsl and Windows terminal. No additional scripts are needed.

I found this to be helpful:

    1. Script to install required tools
    2. Script to start systemd in separate namespace
    3. Script to run script in systemd namespace
    • Almost same ideology, but as single binary.
    • Requires DotNet
    • Requires machined (i.e. not working on CentOS7)
5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy