How to enable Systemd for WSL2 on Windows 11

The Windows Subsystem for Linux (WSL) has seen a number of community supported projects, but systemd has been one of the most requested developer requirements. There have already been projects such as one-script-wsl2-systemd and a genie to implement systemd on WSL2 on Windows 11 and 10. Noticing the passion for implementing systemd on WSL2, Microsoft partnered with Canonical (publisher of Ubuntu) to provide official support. systemd for Windows Subsystem for Linux. And developers can now enable systemd for WSL2 on Windows 11 in 5 easy steps. So, if you are interested, let's go ahead and find out how to enable systemd for WSL2 on Windows 11.

Enable Systemd for WSL2 on Windows 11 (2022)

In this guide, we have mentioned the instructions to enable systemd for Windows Subsystem for Linux on Windows 11, along with a brief explanation on the subject.

What is systemd in linux?

Systemd is a system and service manager for Linux based operating systems. Basically, it is responsible for starting system components and services during the Linux system boot. You could say it's the parent process and it initializes all the other processes, hence its PID (Process ID) is 1. So what's so special about the Windows Subsystem for Linux supporting systemd?

First, systemd brings an almost native programming environment to WSL. Essentially what you get from Ubuntu when you install on bare metal, you get the same environment in WSL. Also, there are many services like Snap, microk8s, Kubernetes, etc. that rely on systemd to work properly. So, with official support from Microsoft, developers can now take full advantage of the true potential of WSL2 and work simultaneously on Windows and Linux without missing anything.

Install the latest version of WSL2

1. First, you need to download a certain version of WSL (version 0.67.6 and higher). Open PowerShell and run the command below to check the current version. If you have an updated version, skip ahead to the next section.

wsl --version

2. If you are using an older version, download the latest WSL package from the Microsoft GitHub page here. here . You don't need to be in the Insider channel to enable systemd for WSL2 on Windows 11.

3. Then install the Windows Subsystem for Linux MSIXBUNDLE package on your Windows 11 PC.

4. After that, open a Windows Terminal with administrator rights. If you already have a Linux distribution installed, skip to the next section.

5. Then go to PowerShell and run the command below. This will install the latest Ubuntu distribution. If you want to install any other Linux distribution, you can install it from the Microsoft Store or run wsl --install to find all available distributions.

wsl --install Ubuntu

Enable Systemd for WSL2 on Windows 11

1. After installing Ubuntu (or your Linux distribution of choice), open PowerShell again as an administrator. Then navigate to "Ubuntu" using the arrow button in the title bar.

2. After setting the username and password, run the command below to edit the "wsl.conf" file using the Nano editor.

sudo nano /etc/wsl.conf

3. Here add the following lines to the file. This will allow you to enable systemd for WSL2 on your Windows 11 machine.

[boot]systemd=true

4. To save and exit the Nano editor, press "Ctrl + O" and press Enter. Then press "Ctrl+X". You have now made the necessary changes.

5. Now you need to close the Windows Subsystem for Linux. To do this, close the Ubuntu tab and switch to the PowerShell tab. Here run the below command.

wsl.exe --shutdown

6. Now start Ubuntu again from the Windows terminal. systemd will now run in the background by default. To check, run the command below and see the status of the service.

systemctl list-unit-files --type=service

7. Now you can install Nextcloud on WSL2 using Snap which relies on systemd to work properly. Here choose your own username and password in the second command. As shown in the screenshot below, all Snap services are working correctly.

sudo snap install nextcloudsudo nextcloud.manual-install USERNAME PASSWORDsnap services

Enable Systemd on Windows Subsystem for Linux

So here are the steps you need to follow to enable systemd for WSL on Windows 11. The best part is that you don't have to go to the insider channel to enable systemd on your Linux subsystem on Windows. You can directly download the package from GitHub and install it right now. Moreover, if you want to install Android apps on Windows 11, please refer to our detailed guide. And to install the Google Play Store on a Windows 11 PC, we have an updated guide for you. Finally, if you have any questions, please let us know in the comments section below.

Related posts