Installing and Configuring Windows Subsystem for Linux (WSL) Distros

Flexibility is essential in the dynamic fields of Linux administration and DevOps. By bridging the gap between the Windows and Linux environments, Windows Subsystem for Linux (WSL) facilitates the development, testing, and deployment of cross-platform applications for professionals. Knowing how to install and setup WSL can enhance your workflow, regardless of your level of experience as a Linux administrator or DevOps engineer.

There are two versions:

  • WSL 1: Faster and lighter file input/output between Linux and Windows.
  • WSL 2: A full Linux kernel that is recommended for its improved performance, Docker compatibility, and authentic Linux behavior.

Why Use WSL for Testing?

WSL allows you to operate complete Linux distributions directly on your Windows computer without the need for a virtual machine or dual-boot configuration. Here is the rationale for why WSL represents a significant advancement in testing:

  • Seamless Integration: Utilize Linux tools, scripts, and applications natively within the Windows environment.
  • Resource Efficiency: Utilize fewer resources than conventional virtual machines, enabling quicker deployment and reduced memory consumption.
  • Improved Productivity: Streamline cross-platform testing without departing from your primary operating system.
  • DevOps Alignment: Replicate production environments to facilitate precise testing and effective troubleshooting.

Step-by-Step Installation Guide

1. Enable WSL on Windows

First, enable the Windows Subsystem for Linux feature:

Run PowerShell as Administrator and execute:

wsl --install

This installs:

  • WSL 2 backend

  • Latest Ubuntu LTS distro by default

After installation:

wsl --set-default-version 2

Optional: Install a Specific Linux Distro

To see available distros:

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 have to install a different Linux distribution, specifically Oracle Linux 9, which is what I need to do. Let’s move forward with the installation in accordance with the instructions.

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:\01\WSL_Backups\Ubuntu24_Snapshot.tar"

Import a Distro (Restore)

wsl --import MyUbuntu D:\WSL\MyUbuntu D:\01\WSL_Backups\Ubuntu24_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

Example configuration file:

[boot]
systemd=true

[network]
generateResolvConf=false

Enable systemd in WSL

If systemd services like systemctl don’t work:
Edit /etc/wsl.conf inside your distro:

sudo nano /etc/wsl.conf

Add:

[boot]
systemd=true

Then run:

wsl --shutdown

and restart the distro.

Accessing Windows Files from WSL

Your Windows drives are available under /mnt:

cd /mnt/c
cd /mnt/d

You can also open Windows apps from WSL:

Using WSL for DevOps or Cloud Tools

You can install:

  • 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

Windows Subsystem for Linux (WSL) is an option to take into consideration if you want to create a development environment on Windows that is similar to that of Linux. Through the use of WSL, you are able to work with Windows apps while simultaneously running a full Linux distribution. You may start utilizing WSL by:

  • You can activate Windows Subsystem for Linux (WSL) by going into the settings for Windows Features.
  • Through the Microsoft Store, you can get your preferred Linux distribution up and running successfully.
  • Your development environment should be configured in the same manner as it would be on Linux.

When creating across many platforms, this setup provides a more consistent experience for the user. You can find thorough information by checking the Microsoft’s official WSL documentation.

Avatar photo

Asif Khan

Responsible and proactive professional with more than 13 years of experience in IT systems, open source software applications, DevOps, Linux systems, and cloud operations. My main goals are to automate things, keep them safe, and make sure they are strong. I am very good at planning and building the infrastructure for services that people really want. I was drawn to the fast-paced world of cloud computing because it has resources that can be scaled up or down as needed. One of my best skills is being able to use a lot of different DevOps tools to set up, release management, and microservices ecosystems, as well as for provisioning, orchestration, and configuration management.