WSL2
Windows Subsystem for Linux 2 (WSL2)
In this article, we’ll guide you through setting up and using WSL2 on your Windows machine.
Enabling WSL
First, enable the Windows Subsystem for Linux feature:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Installing WSL2
To list available distributions, use the following command:
wsl --list --online
The output will show a list of valid distributions that can be installed:
C:\>wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl.exe --install <Distro>'.
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
SLES-12 SUSE Linux Enterprise Server v12
SLES-15 SUSE Linux Enterprise Server v15
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
Ubuntu-22.04 Ubuntu 22.04 LTS
OracleLinux_8_5 Oracle Linux 8.5
OracleLinux_7_9 Oracle Linux 7.9
Installing Debian
First, check if Debian is installed and default:
C:\>wsl --list --all
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
docker-desktop
docker-desktop-data
To install Debian, run:
wsl --install -d Debian
The output will confirm the installation:
C:\>wsl --install -d Debian
Installing: Debian GNU/Linux
Debian GNU/Linux has been installed.
Launching Debian GNU/Linux...
Set Debian as default:
wsl --setdefault Debian
Check if Debian is the default:
C:\>wsl --list --all
Windows Subsystem for Linux Distributions:
Debian (Default)
docker-desktop
Ubuntu-20.04
docker-desktop-data
Setting WSL Version
To set the WSL version for a specific distribution, use:
wsl --set-version <Distro> 2
For example, to set Ubuntu-20.04 to use WSL2:
wsl --set-version Ubuntu-20.04 2
In this command:
wsl
is the command-line tool for managing WSL.--set-version
is an option that specifies you want to set the version of a particular Linux distribution.Ubuntu-20.04
is the name of the Linux distribution you are targeting. In this case, it is Ubuntu version 20.04.2
indicates that you want to set this distribution to use WSL 2.
Listing All Distributions
To list all installed distributions, use:
wsl -l
This will show all distributions installed on your system.
By following these steps, you can effectively set up and manage WSL2 on your Windows machine.