Windows Subsystem for Linux (WSL) lets developers run a GNU/Linux environment—including most command-line tools, utilities, and applications—directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup—source

Install WSL

This section is about how to install WSL for the first time. You might want to read this section if you have already set up WSL and wish to install different Linux distributions.

Install Using WSL Command

You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11 to use the commands below.

  1. Open PowerShell in administrator mode by right-clicking and selecting Run as administrator.

  2. Run the following command:

    wsl --install

    This command will enable the features necessary to run WSL and install the Ubuntu distribution of Linux. The default distribution can be changed, read more here.

    OR

    You can run the following command to install WSL without installing a distribution:

    wsl --install --no-distribution	
  3. Restart the Windows machine.

Manual Installation

If you are using earlier versions of Windows or you wish to install WSL manually, use this guide for manual installation.

WSL Version

WSL 2 is the default version now. Read more about WSL 2 in this section.

To check the default version of WSL, run the following command:

wsl --version

Set WSL Version

  • Individual Linux distributions can be run with either the WSL 1 or WSL 2 architecture.
  • Each distribution can be upgraded or downgraded at any time and you can run WSL 1 and WSL 2 distributions side by side.
  • To set the default version to WSL 1 or WSL 2, when a new Linux distribution is installed, run the following command:
wsl --set-default-version <1|2>
  • WSL version for any already installed distro can be upgraded or downgraded using the following command:
wsl --set-version <Distro> <1|2>

WSL 2

WSL 1

When running Windows inside UTM, WSL 2 usually does not work because it requires nested virtualization (Hyper-V), which is typically unavailable in virtual machines. The recommended solution is to use WSL 1, which does not require virtualization support.

  1. Run PowerShell as Administrator:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  1. Restart Windows (this is very important)
  2. Run in PowerShell:
wsl --set-default-version 1
wsl --install -d Ubuntu-24.04
wsl -l -v

Ubuntu should appear with VERSION 1.

Install Distros

You can list your installed Linux distributions and check the version of WSL each is set to by entering the command:

wsl --list --verbose

To see a list of available Linux distributions available for download through the online store, run the following command:

wsl --list --online

To install a distro, use the following command:

wsl --install -d <DistroName>

If the install process hangs at 0.0%, run the following command, to first download the distribution prior to installing:

wsl --install --web-download -d <DistroName>

To run a specific distribution from within PowerShell without changing your default distribution, use the command:

wsl --distribution <DistroName>

For the complete list of WSL commands, read here.

I am running

Change Default Distribution

By default, the installed Linux distribution will be Ubuntu. To set a different Linux distribution as default, run the following command:

wsl --set-default <DistroName>

Best Practices for Dev Environment

Choose Stable Linux Distro

I have tried NixOS as WSL Linux distribution but there are couple of bugs I faced in the past:

  • Copilot coding agent working weird in VS Code
  • Copilot coding agent mode not applying changes to files residing within the WSL filesystem but instead trying to read / write mounted Windows filesystem
  • A lot of other VS Code related issues

Because of the above reason, I am now using Ubuntu 24.04 LTS as the full-time distro.

Set up Username and Password

https://learn.microsoft.com/en-us/windows/wsl/setup/environment#set-up-your-linux-username-and-password

File Storage

Store your project files on the same operating system as the tools you plan to use.