How to run Linux apps on Windows 11 with WSL2?



With WSL2 (Windows Subsystem for Linux 2) you can run Linux GUI and command line apps directly in Windows without using a (full size) Virtual Machine. Although, WSL2 itself can be considered as a virtual machine, it is very light and optimised specially to run Linux kernel. No wonder it can run Linux Apps almost at native speed and require fewer resources (CPU, memory, and storage) than using a full size Virtual Machine like VMWare or Virtualbox.




How to Install WSL2


Because WSL2 is now already available on Microsoft Store, you can install WSL2 the same way as installing any other app from the store. Open Microsoft Store then search for wsl. Click the "Get" button to start the installation process.




Installing Linux Distribution on WSL2


Before you can use the WSL2, you need to install a Linux Distribution. To see available Linux Distribution, run "wsl --list -- online" command on Windows terminal.





Run "wsl --install <Distro>" to install your prefered Linux Distribution. For example if you want to install Ubuntu, run "wsl --install Ubuntu" on Windows terminal.

Once finished, you will be asked to create user account for Ubuntu. The username does not need to match with your Windows username.





Congratulations, your Ubuntu installation is already finished and ready to use.





Just like other Windows app, you can run Ubuntu from Windows Start Menu.





How to Enable Systemd Support


By default systemd is not enabled in wsl2, so some apps like snap or systemctl will not work on your Linux Distribution.





If you need to use systemd, do the following to enable it.

Step 1:

Open wsl.conf file: sudo nano /etc/wsl.conf


Step 2:

Add the following lines:
[boot]
systemd=true





Step 3:

Press CTRL+O to save and CTRL+X to exit Nano editor.


Step 4:

Close WSL distro Window and run wsl.exe --shutdown from Windows terminal to restart wsl2 instance.


Step 5:

When you run your Linux Distribution again, the systemd support will be enabled.


Let's test our Ubuntu Running on WSL2


To test, I will try to update the Ubuntu first. Open Ubuntu App and run "sudo apt update && sudo apt upgrade -y". Then I will install Shotwell app, a personal photo manager app for Linux. If you have already enabled the systemd support you can install app from snap store, otherwise you can use apt command. Run "sudo apt install shotwell" command to install Showell.

If Everything work properly, you should see Shotwell icon in the Start Menu.