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
- With WSL, developers can access the power of both Windows and Linux at the same time on a Windows machine.
- Developers also have flexibility so install any sort of Linux distribution (such as Ubuntu, Kali, Arch Linux, NixOS, etc.)
- WSL is open-source now. Read more about open source components here.
- Files are stored in an isolated Linux file system, specific to the installed distribution.
- It can run GNU/Linux graphical applications (supports X11 and Wayland)
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.
-
Open PowerShell in administrator mode by right-clicking and selecting
Run as administrator. -
Run the following command:
wsl --installThis 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 -
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 --versionSet 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 2 uses virtualization technology to run a Linux kernel inside of a lightweight utility virtual machine (VM).
- Linux distributions run as isolated containers inside of the WSL 2 managed VM.
- WSL 2 increases file system performance and adds full system call compatibility in comparison to the WSL 1 architecture.
- Read this comparison table for in-detail comparison between WSL 1 and WSL 2.
- There are still few exceptions why you might want to use WSL 1 over WSL 2. Copying and pasting files from WSL 2 filesystem to Windows is very slow.
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.
- 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- Restart Windows (this is very important)
- Run in PowerShell:
wsl --set-default-version 1
wsl --install -d Ubuntu-24.04
wsl -l -vUbuntu 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 --verboseTo see a list of available Linux distributions available for download through the online store, run the following command:
wsl --list --onlineTo 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
File Storage
Store your project files on the same operating system as the tools you plan to use.
