How to install systemd in WSL linux

Mukesh KumarMukesh Kumar
2 min read

Systemd is officially supported in the WSL from Windows 11 onwards. Follow this instruction.

What is systemd?

It is one of the first questions that came to mind when discussing systemd. To find the answer, we have to first know a bit about the sysvinit. If we forget about systemd and other similar systems, then it’s safe to say that sysvinit is the first process started by the kernel when you boot up any Linux or Unix computer. This means that all the other processes are their child in one way or the other.

Once the system is successfully booted, the sysvinit process continues to run and waits for special commands like ‘shutdown’, which are used to shut down a Linux system. That means now the task of the sysvinit process is to gracefully shutdown the system. For many years, the sysvinit remained a perfect system to bring up and shutdown Linux-based systems. But as time passed by, the system became slow and inflexible, especially for modern-day computers.

So, in 2010 systemd was proposed to replace the widely used sysvinit system. Both systems have their own advantages but at last, it was decided to use systemd in place of sysvinit system.

Steps to install/enable systemd in WSL

Set the systemd flag in your WSL distro settings:

Open the file: /etc/wsl.conf in vi/vim editor

If the file does not exist, then create it.

vi /etc/wsl.conf

Add these two lines to it:

[boot]

systemd=true

These two lines can be added anywhere in the existing file. Else in the top if creating a new file.

Save the file.

Go to windows powershell with admin mode then below command:

wsl.exe --shutdown

systemd should be working now.

1
Subscribe to my newsletter

Read articles from Mukesh Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mukesh Kumar
Mukesh Kumar

I am a Software Development lead in a product based company.