Installing and Configuring Windows Subsystem for Linux (WSL) Distros

If you work on Windows but everything you actually deploy to is Linux, WSL solves a problem you’ve probably been working around for years. No dual boot, no VM sitting there eating 4GB of RAM, no SSH into a box somewhere just to test a shell script. You get a real Linux distribution running next to Windows, sharing the same filesystem and the same clipboard.

Two versions exist, and the difference matters:

  • WSL 1: A translation layer. Faster when you’re working on files that live on the Windows side, because there’s no VM boundary to cross.
  • WSL 2: A real Linux kernel in a lightweight VM. Slower across /mnt, much faster inside the Linux filesystem, and the only one that runs Docker properly. Use this one unless you have a specific reason not to.

Why Use WSL for Testing?

The short answer is that it removes the friction. A few things you notice once you’ve been using it a while:

  • Your Linux tools are just there. bash, grep, ssh, make, whatever you need, running natively rather than through some ported build.
  • It starts in about a second and only takes the memory it’s actually using. A VM you have to decide to boot; WSL you forget is running.
  • You can keep several distros side by side. Test the same script on Ubuntu and on Oracle Linux without rebuilding anything.
  • Match your target. If production is RHEL 9, run Oracle Linux 9 locally and stop discovering packaging differences during a deploy.

Step-by-Step Installation Guide

1. Enable WSL on Windows

One command does the whole thing now, which wasn’t always true. Open PowerShell as Administrator and run:


wsl --install

That pulls down the WSL 2 backend and the current Ubuntu LTS as a default distro. You’ll need to reboot afterwards. Once you’re back, pin the default version so anything you install later doesn’t quietly land on WSL 1:


wsl --set-default-version 2

Optional: Install a Specific Linux Distro

Ubuntu is fine, but you’re not stuck with it. To see what Microsoft ships:


wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.

NAME                            FRIENDLY NAME
AlmaLinux-8                     AlmaLinux OS 8
AlmaLinux-9                     AlmaLinux OS 9
AlmaLinux-Kitten-10             AlmaLinux OS Kitten 10
AlmaLinux-10                    AlmaLinux OS 10
Debian                          Debian GNU/Linux
FedoraLinux-43                  Fedora Linux 43
FedoraLinux-42                  Fedora Linux 42
SUSE-Linux-Enterprise-15-SP7    SUSE Linux Enterprise 15 SP7
SUSE-Linux-Enterprise-16.0      SUSE Linux Enterprise 16.0
Ubuntu                          Ubuntu
Ubuntu-24.04                    Ubuntu 24.04 LTS
archlinux                       Arch Linux
kali-linux                      Kali Linux Rolling
openSUSE-Tumbleweed             openSUSE Tumbleweed
openSUSE-Leap-16.0              openSUSE Leap 16.0
Ubuntu-20.04                    Ubuntu 20.04 LTS
Ubuntu-22.04                    Ubuntu 22.04 LTS
OracleLinux_7_9                 Oracle Linux 7.9
OracleLinux_8_10                Oracle Linux 8.10
OracleLinux_9_5                 Oracle Linux 9.5
openSUSE-Leap-15.6              openSUSE Leap 15.6
SUSE-Linux-Enterprise-15-SP6    SUSE Linux Enterprise 15 SP6

I wanted Oracle Linux 9 rather than Ubuntu, since that’s closer to what I work against. Installing a named distro looks like this:


wsl --install --distribution OracleLinux_9_5
wsl: Using legacy distribution registration. Consider using a tar based distribution instead.
Downloading: Oracle Linux 9.5
Oracle Linux 9.5 has been downloaded.
Distribution successfully installed. It can be launched via 'wsl.exe -d Oracle Linux 9.5'
Launching Oracle Linux 9.5...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username: asif
Changing password for user asif.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
Installation successful!

Managing WSL Distros

List Installed Distros


wsl --list --verbose

or shorthand:


wsl -l -v

  NAME                STATE           VERSION
* Ubuntu-24.04        Stopped         2
  FedoraLinux-43      Stopped         2
  Ubuntu              Stopped         2
  OracleLinux_8_10    Stopped         2
  OracleLinux_9_5     Stopped         2
  Ubuntu-22.04        Stopped         2

Set Default Distro


wsl --setdefault OracleLinux_9_5
The operation completed successfully.

wsl --list --verbose
  NAME                STATE           VERSION
* OracleLinux_9_5     Stopped         2
  FedoraLinux-43      Stopped         2
  Ubuntu              Stopped         2
  Ubuntu-24.04        Stopped         2
  OracleLinux_8_10    Stopped         2
  Ubuntu-22.04        Stopped         2

Set WSL Version (1 or 2)


wsl --set-version <distro-name> 2

Launch a Specific Distro


wsl -d Ubuntu-24.04
user@DESKTOP:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble

Terminate the instance


wsl --terminate FedoraLinux-43

wsl --list --verbose
  NAME                STATE           VERSION
* OracleLinux_9_5     Stopped         2
  FedoraLinux-43      Running         2
  Ubuntu              Stopped         2
  Ubuntu-24.04        Stopped         2
  OracleLinux_8_10    Stopped         2
  Ubuntu-22.04        Stopped         2

wsl --terminate FedoraLinux-43
The operation completed successfully.

wsl --list --verbose
  NAME                STATE           VERSION
* OracleLinux_9_5     Stopped         2
  FedoraLinux-43      Stopped         2
  Ubuntu              Stopped         2
  Ubuntu-24.04        Stopped         2
  OracleLinux_8_10    Stopped         2
  Ubuntu-22.04        Stopped         2

Shut down all WSL instances


wsl --shutdown

Unregister (delete) the distribution


wsl --unregister Ubuntu-22.04
Unregistering.
The operation completed successfully.

wsl --list --verbose
  NAME                STATE           VERSION
* OracleLinux_9_5     Stopped         2
  FedoraLinux-43      Stopped         2
  Ubuntu              Stopped         2
  Ubuntu-24.04        Stopped         2
  OracleLinux_8_10    Stopped         2

Starting and Stopping WSL

Start WSL


wsl

Start a Specific Distro


wsl -d Ubuntu-24.04

Stop All Running Instances


wsl --shutdown

Export, Import, and Backup WSL

Export a Distro (for Backup)


wsl --export Ubuntu-24.04 "D:1WSL_BackupsUbuntu24_Snapshot.tar"

Import a Distro (Restore)


wsl --import MyUbuntu D:WSLMyUbuntu D:1WSL_BackupsUbuntu24_Snapshot.tar --version 2

Unregister (Delete) a Distro


wsl --unregister FedoraLinux-43
Unregistering.
The operation completed successfully.

wsl --list --verbose
  NAME                STATE           VERSION
* OracleLinux_9_5     Stopped         2
  Ubuntu              Stopped         2
  Ubuntu-24.04        Stopped         2
  OracleLinux_8_10    Stopped         2

Useful WSL Configuration Commands

View WSL Config


cat /etc/wsl.conf

On a fresh distro this file usually doesn’t exist yet. A reasonable starting point:


[boot]
systemd=true

[network]
generateResolvConf=false

Enable systemd in WSL

This is the one that catches people out. Run systemctl on a fresh distro and you get an error about not being booted with systemd, because WSL used to start distros without an init system. Newer builds support it, but you have to ask. Edit the file inside the distro:


sudo nano /etc/wsl.conf

Add:


[boot]
systemd=true

Save it, then shut WSL down completely from PowerShell. A restart of the distro alone won’t do it, the whole subsystem has to stop:


wsl --shutdown

Start it again and systemctl will work.

Accessing Windows Files from WSL

Your Windows drives are mounted under /mnt, one directory per drive letter:


cd /mnt/c
cd /mnt/d

It works in both directions. You can launch Windows programs from a Linux shell by name, so notepad.exe or explorer.exe . opens what you would expect. One warning though: keep your actual project files on the Linux side, under your home directory rather than under /mnt. Anything involving lots of small file reads, a git status on a large repo or an npm install, is dramatically slower across the /mnt boundary on WSL 2. Not slightly slower. Dramatically.

Using WSL for DevOps or Cloud Tools

This is where WSL earns its keep. Everything you would normally install on a Linux workstation installs here the same way:

  • Docker Desktop (uses WSL2 backend)

  • kubectl, minikube, or kind for Kubernetes

  • Terraform, Ansible, AWS CLI, etc.


sudo apt update && sudo apt install -y docker.io kubectl ansible

Summary

The whole thing comes down to about four commands. wsl –install to get started, wsl -l -v to see what you have, wsl -d to launch a particular one, and wsl –shutdown when something needs a clean restart. Everything else in this post is a variation on those.

Three things worth remembering, because they’re the ones that cost time:

  • Keep your files in the Linux home directory, not under /mnt, or you’ll spend your life waiting on file operations.
  • systemd needs enabling in /etc/wsl.conf, and needs a full wsl –shutdown before it takes effect.
  • Export your distros occasionally. A tar snapshot is cheap and it means an experiment gone wrong costs you a restore instead of a rebuild.

Microsoft’s official WSL documentation covers the rest, including the networking options I’ve skipped over here.

Asif Khan

Asif Khan

DevOps, Linux, and Cloud engineer with 10+ years building infrastructure that stays up, and automation so I do not have to fix it at 2am. My focus is automation, security, and systems built to survive failure, using Infrastructure as Code, CI/CD, containers, monitoring, and cloud platforms instead of manual fixes. This blog is where I write down what worked, and just as often what didn't the first time around. Real tutorials you can run yourself, troubleshooting notes pulled from actual outages, and the kind of detail you only get once you've hit the problem firsthand. If you're trying to get Linux, DevOps, and cloud infrastructure to behave, that's what you'll find here: reproducible solutions you can understand, test, and apply in your own environment.