How to install and configure the Windows Subsystem for Linux 2 (WSL2)

  • WSL2 allows you to run real GNU/Linux distributions within Windows with better performance and compatibility than WSL1.
  • The installation can be done with the wsl --install command or manually by enabling features, kernel and distro.
  • It is possible to manage multiple distributions, switch between WSL1 and WSL2 versions, and use WSL with Docker and VS Code.
  • Security, updates, and good configuration practices are key to leveraging WSL2 in development and enterprise environments.

Install and configure the Windows Subsystem for Linux 2 (WSL2)

If you develop in Windows but need the Linux ecosystem, the Windows Subsystem for Linux 2 (WSL2) It's probably one of the best tools you can install on your computer. It lets you have a real GNU/Linux distribution integrated into Windows, with its terminal, packages, and even graphical applications, without struggling with cumbersome virtual machines or dual-boot configurations.

In this guide we will see How to install and configure WSL2 step by step In Windows 10 and Windows 11, what requirements do you need, how to choose your favorite distribution (Ubuntu, Debian, Kali, Fedora, etc.), how to check which version of WSL you are using, how to upgrade from WSL1 to WSL2, how to manage multiple distros at once, and what best practices to follow to get the most out of it in development and business environments.

What is WSL2 and why is it worth using?

The Windows Subsystem for Linux, or WSL, is a feature of Windows that allows you to run a complete Linux environment inside Windows without relying on a traditional virtual machine or dual booting. The WSL2 version uses a real Linux kernel running in a lightweight virtual machine thanks to the Windows virtualization platform (Hyper-V and Virtual Machine Platform).

What is Oreaon 10?
Related article:
Oreon 10: what this Linux distro offers, versions and advantages

With WSL2 you can install GNU/Linux distributions such as Ubuntu, Debian, Kali, Fedora, Alpine or Arch From the Microsoft Store or manually, run Bash commands, development tools, servers, Docker containers, and even graphical user interface applications, all integrated with the Windows file system.

Compared to WSL1, WSL2 offers improved input/output performance (disk and network)It offers improved compatibility with native Linux tools and full support for Linux-based Docker containers. This makes it particularly interesting for web development, data science, microservices, CI/CD pipelines, and systems administration.

Prerequisites for installing WSL2

Before you start installing anything, it's a good idea to make sure your system meets the requirements. minimum Windows requirementsTo use modern WSL commands in simplified mode you need:

  • Windows 10 version 2004 or later (build 19041 or higher) or
  • Windows 11 in any of its compatible editions.

If you have Windows 10 but with a build earlier than 19041, you can still use WSL, but you will have to resort to manual installation process enabling features and manually downloading the kernel.

In even earlier versions, or in some Windows Server or LTSC editions, the simplified command may not work. wsl -install and you'll have to follow the installation steps. In any case, check your version by pressing Windows + R, typing winver and checking the window that appears.

Additionally, in Windows 10 you need the system to be 64-bit and build 18362 or higher To work with WSL2 reliably, you'll need to use a 32-bit Windows system. If you have a 32-bit Windows system, you won't be able to use WSL and will have to opt for alternatives like Git Bash or traditional virtualization.

Quick method: Install WSL2 with a single command

In recent versions of Windows 10 and Windows 11, you have a command that automates the entire WSL installation process (Windows features, kernel and default distro) without you having to manually check boxes.

The basic steps are:

  1. OPEN PowerShell as administrator (Start > search "PowerShell" > right-click > Run as administrator).
  2. Run the command:
    wsl --install
  3. Restart your computer when Windows prompts you to do so.

This command will automatically activate the features required for WSL and the Virtual Machine PlatformIt will download the Linux kernel and, by default, install Ubuntu as an initial distribution. Later you can change distros without any problem.

The first time you boot the newly installed distro, a console with an installation message and file extraction. That process may take a few minutes, but subsequent startups are usually almost instantaneous.

Install and configure the Windows Subsystem for Linux 2 (WSL2)

Step-by-step manual installation of WSL and WSL2

If the simplified command is not available in your version, or you prefer to have a finer control of each stepYou can install WSL2 manually. The standard process on Windows 10 and 11 is divided into several steps.

Step 1: Activate the Windows Subsystem for Linux

First, you need to enable the optional feature that allows you to run Linux within Windows. To do this, open PowerShell as administrator and runs:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

This command installs the basic WSL componentAt this point, if you only wanted to use WSL1 you could restart and go directly to installing a distribution, but to take advantage of WSL2 it is important to continue with the next step before restarting.

Step 2: Enable the Virtual Machine Platform

WSL2 relies on a lightweight virtualization layer, so enabling the feature is mandatory. VirtualMachinePlatform. Back in PowerShell with administrator privileges, run:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

For these changes to be applied correctly, it is now necessary Restart the systemWithout that restart, WSL2 will not function properly.

Step 3: Install or update the Linux kernel for WSL2

WSL2 uses a Windows-specific Linux kernelwhich is distributed as a standalone package. If you don't have it installed or want to stay up to date, you can do so in two ways:

  • Downloading the kernel update MSI from the official WSL version page on GitHub or in the Microsoft documentation, and running it like any installer.
  • Using the WSL command itself:
    wsl --update
    which downloads and installs the latest kernel version available from the Microsoft Store.

Once the package is installed, you will have a Linux kernel ready for WSL2 on your system. This is essential for the distros to function in mode 2.

Step 4: Set WSL2 as the default version

So that all new Linux distributions you install are configured directly with WSL2 instead of WSL1, open PowerShell and run:

wsl --set-default-version 2

If you get errors at this point, it's usually an indication that The kernel update has not been installed correctly or that the Virtual Machine Platform has not been enabled. It is advisable to review these steps before continuing.

Step 5: Install a Linux distribution

With WSL enabled and the WSL2 kernel running, you can install your preferred Linux distribution. You have several options depending on your environment:

Install a distro from the Microsoft Store

The most convenient method is to use the Microsoft Store:

  1. Open Microsoft Store from the Start menu.
  2. Find the desired distribution (for example, Ubuntu, Debian, Fedora, Kali, openSUSE, Alpine, etc.).
  3. Click on Get / Install and wait for the download to finish.
  4. Once installed, click on Start or open it from the Start menu.

The first time it runs, the distro will complete its internal installation (decompression and basic configuration) and it will ask you to create a default Unix user.

Manual installation using .appx or .wsl packages

If your environment does not allow the use of the Microsoft Store (for example, in Windows Server, LTSC, or corporate computers with restrictive policies), you can install the distributions by downloading the packages directly:

  • Visit the official download links for WSL distributions (Ubuntu, Debian, Kali, Oracle Linux, Fedora Remix, etc.).
  • Download the file .appx o .wsl from the distribution to a local folder.
  • In PowerShell, navigate to that folder and run:
    Add-AppxPackage .\nombre_paquete.appx

You can also use commands like Invoke-WebRequest o curl.exe To download packages from the command line, for example:

Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing

Once the package is installed, you will be able to Start the distro by double-clicking on the file. or by searching for it by name in the Start menu. If you're using Server Core, you'll need to follow Microsoft's specific instructions to convert the .appx file to ZIP and install it manually.

Choosing and changing the default Linux distribution

When you use the command wsl -install Without any parameters, Windows installs Ubuntu by default. If you prefer another distribution (for example, Debian or Kali), you can specify it during installation with:

wsl --install -d Debian

To see the list of distributions available to install via the online store or WSL, run the following in PowerShell:

wsl.exe --list --online

If you want to change the distro that is considered default (the one that starts when you simply run wsl (without parameters), you can do it with:

wsl.exe --set-default <NombreDistro>

For example:
wsl -s Debian
will cause that, when launched wsl npm init From PowerShell, that command is executed within the Debian distribution.

Creating a Linux user and getting started

The first time you start a newly installed distribution, a message will appear indicating that the installation may take a few minutes, and then the system will ask you create a default Unix user:

Installing, this may take a few minutes...
Please create a default UNIX user account.
Enter new UNIX username:

It's important to choose this user carefully, as you'll be using it regularly in WSL. Here are some helpful recommendations:

Create a Live USB with TAILS Linux
Related article:
How to create a Live USB with Tails Linux to browse without being tracked
  • Use a name in lowercase, without accents or special characters.
  • It does not have to match your Windows user (in fact, it is recommended that it be different).
  • Remember that your personal folder will be of the type /home/usuario.

Next, you will need to define a password for that userKeep it safe, because you'll need it for administrative operations within the distribution, especially if you use sudo.

Check which version of WSL you are using

When you have multiple distros installed, each one may be using WSL1 or WSL2To see the list with details of each one, open PowerShell and run:

wsl.exe --list --verbose

This command displays the installed distributions, whether they are running or stopped, and the associated WSL version. Another commonly used variant is:

wsl -l -v

If you want to change the default version for new installations between WSL1 and WSL2, you can use:

wsl.exe --set-default-version <1|2>

Upgrade from WSL1 to WSL2 (or vice versa)

If you previously configured WSL1 or your distro was installed in that version and now want to enjoy the WSL2 performance and compatibility advantagesYou can easily migrate it. Just run the following command in PowerShell:

wsl.exe --set-version <Distro> <1|2>

For example:
wsl --set-version Ubuntu 2
This will convert your Ubuntu distro to use WSL2. The process may take a while if your system has many files, but it only needs to be done once.

If needed you can also downgrade from WSL2 to WSL1 using the same command with a 1 as the version. This can be useful in certain very specific compatibility situations.

If you installed WSL manually before the command existed wsl -install, you may have to Enable the Virtual Machine Platform and manually install the kernel package in order to use WSL2.

How to run and manage multiple distributions with WSL?

WSL allows you to have as many Linux distros as you want Installed in parallel: you can combine Ubuntu for general development, Debian for production environments, Kali for security testing, Alpine for lightweight services, etc.

There are several common ways to access these distributions once installed:

  • Windows Terminal (Recommended): You can open multiple tabs and panels, each with a different distro or with PowerShell, cmd, Azure CLI, etc., and customize colors, fonts, backgrounds, and keyboard shortcuts.
  • From the start menuby searching for the name of the distro (for example, "Ubuntu" or "Debian") and launching it as if it were just another application.
  • By directly invoking the distribution name in PowerShell if it is mapped (for example, writing ubuntu).
  • Simply running wsl.exe in PowerShell to open the default distro in the current console.
  • Using wsl [comando] all with execute a specific Linux command without starting a new interactive session, such as wsl -l -v o wsl pwd.

If you have ever entered WSL within a PowerShell console and want to return to the Windows interpreter, simply type exit to close the distro session.

Best practices for configuration and use in development

Once you have WSL2 up and running, it's worth spending some time on fine-tune the settings To make your development environment comfortable and efficient, here are some recommendations:

  • Correctly configure your user, shell and language within the distro (for example, by installing your favorite shell, adjusting locales, etc.).
  • Install and customize Windows Terminal to conveniently manage multiple sessions with tabs, shortcuts, and themes.
  • Setup Git and version control directly in the Linux distro, using ssh for your remote repositories.
  • Use VS Code with the Remote – WSL extension to edit and debug projects within Linux without leaving Windows.
  • Be mindful of where you store your files: it's more efficient to work with projects within the distro file system (/home/usuario/proyecto) that in mounted Windows paths.
  • If you manage databases or heavy services, consider the memory and CPU limit settings using advanced WSL settings when working with heavy loads.

Integration with Docker, cloud, and enterprise environments

One of the great attractions of WSL2 is its integration with containers and cloud servicesBy having a real Linux kernel, Docker Desktop can use WSL2 as a backend, offering much better performance than classic virtualization on Windows.

In corporate environments, WSL2 facilitates the creation of homogeneous CI/CD pipelineswhere developers work on Linux on Windows and deploy to Linux servers in the cloud (AWS, Azure, etc.) with minimal changes between environments.

Furthermore, it is becoming increasingly common to combine WSL2 with artificial intelligence projects, AI agents, data analysis and business intelligence, taking advantage of the wide range of Linux tools (Python, R, AI frameworks) while maintaining integration with Windows desktop tools such as Power BI or other enterprise clients.

In these types of scenarios, it is essential to have good cybersecurity policies and backups, manage access to sensitive data and ensure proper segmentation between development and production environments.

Safety and maintenance in WSL2

Although WSL2 runs within a lightweight Windows managed virtual machineIt is still a complete Linux environment, so it is advisable to apply security measures similar to those used on any server:

  • Update frequently the distro packages (apt update && apt upgrade in Debian/Ubuntu, for example).
  • Use users without privileges for everyday life and resort to sudo only when necessary.
  • Configure and use SSH keys instead of passwords for remote access.
  • Protect both the Windows system and the distros with a good security and firewall solution.
  • Plan a strategy of backups of important datawhether from Windows or Linux, and if possible, integrate them with cloud services.

It's also a good idea to check the WSL updates to wsl --update And, if you're interested in trying out new features before anyone else, consider using the parameter --pre-release or join the Windows Insider program.

Test features in a preview version of WSL

If you like to stay up-to-date, you can access the WSL news in preview phaseThere are two paths:

  • join the Windows Insider Program and choose a channel (Development Channel, Beta, Preview, etc.) to receive Windows builds with new WSL features.
  • Without touching your Windows channel, run:
    wsl.exe --update --pre-release
    to get the preview version of WSL directly from Microsoft.

This is especially useful for testing new GPU capabilitiesperformance improvements or extended file system support before they reach the stable version, although it must be assumed that there may be bugs or unstable behavior.

Install WSL without an internet connection

In closed environments or those with restricted internet access, it is also possible to install WSL using a offline procedureThe general flow would be:

  • Download to a computer with internet access the WSL's latest MSI package from the version page on GitHub and install it on the target machine.
  • Open PowerShell with administrator privileges and enable the Virtual Machine Platform with:
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    restarting afterwards.
  • Installing a distribution through a .wsl or .appx file that you have previously downloaded, using Add-AppxPackage or by following the procedure recommended by Microsoft for Server.

This way you can have a fully functional WSL2 environment even on networks where the Microsoft Store or direct downloads are blocked.

Linux file attributes
Related article:
Linux commands to obtain hardware information (comparison with Windows)

With all of the above, you have a complete overview to understand what WSL2 is, what requirements you need, how to install it both with the quick command and manually, how to choose and manage various distributions, how to upgrade between WSL1 and WSL2, how to integrate Docker and modern development tools, and what security and maintenance aspects you should take care of to ensure your Linux environment on Windows is stable, secure, and truly useful in your daily work as a developer or technical professional. Share the guide and more people will know how it's done.