The issue opens pre-filled with this page title and URL.
WSL2 (Windows Subsystem for Linux 2) runs Linux directly inside Windows, without dual-boot (two systems installed side by side, chosen at startup) and without a heavy virtual machine to manage. You keep Windows as it is, and you get a Linux terminal with bash, Python and every command-line tool that only exists on Linux. This page takes a Windows PC to an open Ubuntu window, with your user created and the system up to date. On Windows 11, a single command is enough; Windows 10 is still supported by WSL, with the limits pointed out in the prerequisites. For a full Linux in its own virtual machine, see
Install Linux in a virtual machine instead.
What you will learn
This guide walks you through the installation and configuration of WSL2, from
the hardware prerequisites to graphical applications:
Skill
What you will be able to do
Check the prerequisites
Confirm that your PC supports WSL2
Turn on virtualisation
Configure the BIOS if needed
Install WSL2
One command to set everything up
Open Ubuntu
Create your Linux user and update the system
Choose a distribution
Ubuntu by default, or another one from the Microsoft catalogue
Manage your distributions
List, stop, back up and restore
Run graphical apps
Run Linux applications with an interface
Offline installation
Install WSL without an Internet connection
Swipe to see more
Understanding WSL2
Before typing a single command, you need to know which of the two versions of
WSL you are using. The choice is made distribution by distribution, and it
changes both performance and compatibility. This section compares the two
architectures, then explains why the recommendation almost always leans the same
way.
WSL1 vs WSL2: what is the difference?
WSL1 and WSL2 coexist and are chosen distribution by distribution. WSL1 translates Linux system calls into Windows calls. WSL2 embeds a real Linux kernel in a lightweight virtual machine managed by Hyper-V, the Windows hypervisor (the software that runs virtual machines).
Aspect
WSL1
WSL2
Architecture
Translation layer
Real Linux kernel
Read/write (I/O) of Linux files
Average
High
Read/write (I/O) of Windows files
High
Average
Compatibility
Partial
Near-total
RAM used
Minimal
Dynamic (up to 50% of the RAM by default)
Swipe to see more
The two performance rows read as mirror images. WSL1's translation reads Windows files fast but Linux files slowly. WSL2's virtual machine does the opposite, because its Linux files live in a virtual disk and access to C: goes through a network protocol.
Use WSL2 unless you work mostly on files stored on the Windows side: in that
case, WSL1 can remain faster for file access.
WSL2 embeds a Linux kernel built and distributed by Microsoft. Linux
applications find there what they expect, hence the near-total compatibility.
Tools that rely on the kernel benefit from it: Docker Desktop, for example,
uses the WSL 2 engine to run Linux containers on Windows.
Prerequisites
Two conditions decide everything else: a recent enough Windows version, and
hardware virtualisation turned on in the firmware. Check both before
starting the installation.
Required Windows version
WSL2 works on Windows 11, or on Windows 10 version 2004 or later. The number that matters is not "Windows 10" but the build number: a machine still on a build older than 19041 refuses the wsl --install command, even though it does show Windows 10. To read it, press Win+R, type winver and confirm (the command also works in a terminal):
Terminal window
winver
You must see at least:
Windows 11: every supported version
Windows 10: version 2004 (build 19041 or later)
Windows 10 has no longer been supported by Microsoft since 14 October 2025: only the Extended Security Updates (ESU) programme still provides fixes, until 12 October 2027 for individuals (pages read on 2026-11-13). WSL itself still lists Windows 10 among the supported versions. For a new machine, prefer Windows 11.
Turn on virtualisation (BIOS/UEFI)
WSL2 relies on Hyper-V, which requires the processor's hardware virtualisation (Intel VT-x or AMD-V). On most recent PCs it is already turned on: check before touching the BIOS. Open Task Manager (Ctrl+Shift+Esc), Performance tab, then CPU: the Virtualization line must show "Enabled".
If it shows "Disabled", or if the installation fails with a virtualisation error, turn it on in the BIOS/UEFI. This is the settings menu of the motherboard, which opens at startup before Windows.
Restart your PC and enter the BIOS/UEFI
The key depends on the manufacturer (it is shown at startup); the table in the next step gives the most common ones.
Find the virtualisation setting
Its name and location vary by manufacturer:
Manufacturer
BIOS key
Location
Setting name
ASUS
F2 / Del
Advanced → CPU Configuration
Intel VT-x / SVM Mode
Dell
F2
Virtualization Support
Enable Virtualization
HP
F10 / Esc
System Configuration → Device Configuration
Virtualization Technology
Lenovo
F1 / F2
Security → Virtualization
Intel VT-x / AMD-V
MSI
Del
OC → CPU Features
SVM Mode / Intel VT-x
Acer
F2
Advanced
Intel VT / AMD SVM
Gigabyte
Del
M.I.T → Advanced CPU Settings
SVM / VT-x
Swipe to see more
This table sums up the most common paths. The setting must be on Enabled.
Save and restart
Usually F10 → Save & Exit.
Installing WSL2
Two paths lead to the same result, and the choice depends on your network
access. On a connected machine, wsl --install chains on its own the feature
activation, the kernel download and the installation of a distribution. Behind a
filtering proxy or on an isolated machine, the same sequence is redone by hand,
file by file. Start with the standard method: the offline method only makes
sense if this one fails at download time.
Standard method (with Internet)
A single PowerShell command run as administrator turns on the Windows features, downloads the kernel and installs a distribution. Five steps take you from a blank PC to an open Ubuntu window. The point not to miss is the restart between step 2 and step 4: Microsoft asks you to restart the PC after wsl --install, and the installation of Ubuntu continues at that restart.
Open PowerShell as administrator
Right-click Start → Windows Terminal (Admin)
Or: Win+X → Terminal (Admin)
Start the installation
Terminal window
wsl --install
This command:
Turns on the required Windows features
Downloads the WSL2 Linux kernel
Installs Ubuntu as the default distribution
Restart your PC
Terminal window
Restart-Computer
Set up Ubuntu on first launch
After the restart, Ubuntu starts by itself and finishes its installation, which takes a few minutes. If no window opens, type Ubuntu in the Start menu and click the application. Ubuntu asks you to create your Linux user, then a password. When you type the password, nothing is displayed, not even dots: this is normal. Type it anyway, then confirm it. Remember it, because Linux will ask for it again.
Enter new UNIX username: your_name
New password:
Retype new password:
Check the prompt and update Ubuntu
When the installation is finished, the window shows a prompt like your_name@PC:~$: your user, the name of your PC, then the current directory. You are in a Linux terminal. Update the packages before going on. The sudo command asks for your password, again without displaying anything:
Terminal window
sudoaptupdate && sudoaptupgrade-y
To reopen Ubuntu after closing it, type Ubuntu in the Start menu, or wsl in PowerShell. The lesson Open a terminal and understand the prompt explains how to read this prompt.
To check that Ubuntu runs on WSL2, open PowerShell and run wsl --list --verbose: the VERSION column must show 2.
Ubuntu is only the default distribution, not a requirement. The -d option installs
another one, and you can install several side by side on the same machine:
Terminal window
wsl --install -d Debian
The wsl --list --online command shows the catalogue of names accepted by -d.
It is the only authoritative list: a name found elsewhere fails if the image is
not published for your WSL version. If the download stays stuck at 0.0%,
Microsoft advises wsl --install --web-download -d <Distribution>.
Offline method (without Internet)
In a disconnected environment or behind a filtering proxy, wsl --install fails when downloading the kernel. The procedure below redoes by hand what the command automates: turn on two Windows features, install the kernel package, then provide the distribution as a file. Microsoft documents it under the title Manual installation steps for older versions of WSL. Plan a connected machine to fetch the two files, and a means of transfer (USB stick, internal share).
On a connected PC, download the official package for your architecture,
wsl_update_x64.msi or wsl_update_arm64.msi, from the
Manual installation steps
page on Microsoft Learn. Transfer the .msi file and install it.
Make WSL2 the default version
Terminal window
wsl --set-default-version 2
Install a distribution manually
A distribution's Microsoft Store page does not let you download its
package. Take the direct link published in the
Downloading distributions
section of the same page, for example for Ubuntu 22.04 and Debian:
On the target machine, install the package then start the distribution:
Terminal window
Add-AppxPackage .\Ubuntu.appx
Renaming the .appx to .zip to extract it is only the Windows Server
variant, where Add-AppxPackage is not available.
Essential commands
Here are the PowerShell commands you will need day to day. They all run from a Windows terminal, not from inside WSL: they can therefore act on a stopped distribution.
Managing distributions
Once WSL is installed, you can have several Linux distributions side by side. These commands list them, start them, stop them or change the default distribution, each one by its name.
Terminal window
# List the installed distributions
wsl --list --verbose
# Start a specific distribution
wsl -d Ubuntu
# Set the default distribution
wsl --set-default Ubuntu
# Stop every distribution
wsl --shutdown
# Stop a specific distribution
wsl --terminate Ubuntu
Managing WSL versions
You can convert an existing distribution from WSL1 to WSL2 (or the other way round) without reinstalling it. It is useful if you migrated from an older version of Windows.
Terminal window
# Check the WSL version
wsl --version
# Convert a distribution WSL1 → WSL2
wsl --set-version Ubuntu 2
# Update WSL
wsl --update
Accessing files
The file systems are reachable from both sides. On the Windows side, two paths
lead to the distribution: \\wsl.localhost\ and the older \\wsl$\. They point
to the same place, and the distribution must be running. The table gives the
first one:
From
To
Path
Windows
Linux
\\wsl.localhost\Ubuntu\home\user\
Linux
Windows
/mnt/c/Users/YourName/
Swipe to see more
Linux graphical applications
WSL2 runs Linux graphical applications thanks to WSLg, a component that starts together with the distribution and relays the display to the Windows desktop. A Linux window appears like an ordinary Windows window, with its entry in the taskbar. There is no third-party X server to install, and no variable to export.
Microsoft Learn sets the prerequisite: Windows 11 or Windows 10 build 19044 or later, an up-to-date WSL, and the manufacturer's graphics driver (Intel, AMD or NVIDIA) installed on the Windows side.
Checking support
WSLg provides a Wayland display server and an X11 bridge in the distribution. To test it, read the DISPLAY variable: if it is empty, WSLg is not active and no window will open, whatever package is installed. One possible cause is a WSL that is too old, which wsl --update fixes.
Terminal window
# In WSL2, check that DISPLAY is set
echo$DISPLAY
# Must show something like :0
Installing a graphical application
A Linux graphical application installs like a command-line application, with the distribution's package manager. No display configuration is needed. Updating the package index first (apt update) avoids installing an outdated version, and apt install adds on its own the GTK or Qt libraries the application depends on.
Terminal window
# Update the packages
sudoaptupdate && sudoaptupgrade-y
# Install a graphical editor (example: GNOME Text Editor)
sudoaptinstallgnome-text-editor-y
# Start the application
gnome-text-editor &
The application opens in a classic Windows window, integrated into the taskbar.
Common applications
Here are a few common graphical applications to install in WSL2. They integrate with Windows: icons in the Start menu, resizable windows, copy and paste between Windows and Linux.
Terminal window
# File browser
sudoaptinstallnautilus-y
# Code editor (lightweight)
sudoaptinstallgeany-y
# Advanced terminal
sudoaptinstallterminator-y
After installation, start each application by its name in the WSL terminal, for
example nautilus &. The ampersand & gives control back to the terminal
instead of blocking it while the window stays open.
The terminal is not needed afterwards: these applications appear in the Windows
Start menu, among the Windows applications, and can be pinned to the
taskbar like any of them. WSLg publishes these shortcuts from the .desktop
files installed by the package.
Advanced configuration
Two configuration files coexist, and it is easy to mix them up. The diagram
shows where each one lives: .wslconfig is a single Windows file that sets the
virtual machine shared by all distributions; each distribution has its own
/etc/wsl.conf, which only concerns that one.
Remember the split rule: everything about the memory, processors and network
of the VM is global, everything about systemd and mounts is local.
Limiting resources (.wslconfig)
By default, the WSL2 virtual machine can use up to 50% of the host's memory, plus a swap of 25% of that memory. The .wslconfig file sets a ceiling, which prevents a build in WSL from slowing down the rest of the machine. It applies to all distributions at once, unlike wsl.conf covered just after. Recent versions also offer the WSL Settings application, in the Start menu, which writes this same file.
The file is created at this location: C:\Users\YourName\.wslconfig
[wsl2]
memory=4GB
processors=2
swap=2GB
localhostForwarding=true
After a change, restart WSL:
Terminal window
wsl --shutdown
Per-distribution configuration (wsl.conf)
Where .wslconfig sets the global virtual machine on the Windows side, /etc/wsl.conf sits inside each distribution and only concerns that one. It is the file that turns on systemd, the Linux service manager. Microsoft states that many distributions, Ubuntu included, start it by default. On a distribution that does not turn it on, without this setting, systemctl returns an error and no Linux service starts at launch.
Microsoft specifies that the [boot] section is only available on Windows 11 and Windows Server 2022. Create the file with root rights:
[boot]
systemd=true
[automount]
enabled=true
root=/mnt/
options="metadata,umask=22,fmask=11"
[network]
generateResolvConf=true
This configuration:
Turns on systemd (Linux services)
Sets up the automatic mounting of Windows drives
Generates /etc/resolv.conf automatically
VS Code integration
VS Code works here in client-server mode: the interface stays a Windows application, but a VS Code server is installed automatically in the Linux distribution, and it is the one that runs the terminal, the extensions, the debugger and the language tools. Practical consequence: extensions must be installed on the WSL side, and an extension present on the Windows side may appear greyed out until you turn it on in the remote context.
Install the Remote - WSL extension
In VS Code, install "Remote - WSL" (or "WSL" in recent versions).
Open a WSL project
From WSL:
Terminal window
cd~/my-project
code.
Or from VS Code: Ctrl+Shift+P → "WSL: Connect to WSL"
Develop natively
VS Code runs on the Windows side but every tool (terminal, extensions) runs in WSL.
Troubleshooting
The WSL failures covered here fall into three families: virtualisation missing or
turned off, an outdated component that wsl --update brings up to date, and a
distribution whose internal state is broken. The "Common errors" subsection
mostly handles the first two with a lookup table. The third is fixed by the
reset, which destroys data and must therefore be prepared before running it.
Common errors
The first column sums up messages whose exact wording varies with the WSL version and the Windows language: look for the keyword (virtualization, update, elevation) in what your terminal shows. The first three errors are fixed outside the distribution (BIOS, rights, WSL update). The fourth concerns the installation of Ubuntu itself. The fifth changes the configuration of the virtual machine: it needs a wsl --shutdown before the fix takes effect. The last one is a matter of network and VPN.
Error
Likely cause
Solution
"Virtualization disabled"
BIOS badly configured
Turn on VT-x/AMD-V in the BIOS
"WSL 2 requires an update"
Outdated kernel
wsl --update
"The requested operation requires elevation"
Insufficient rights
Run PowerShell as admin
No Ubuntu window after the restart
The installation of Ubuntu did not finish
Type Ubuntu in the Start menu; otherwise run wsl --install -d Ubuntu again
Distribution that does not start
Not enough RAM on the Windows host
Lower memory in .wslconfig
Network unavailable
VPN interference
Turn off the VPN or configure the firewall
Swipe to see more
Resetting a distribution
If a distribution is corrupted, the only reset goes through unregistering it,
which wipes everything: export what matters first.
Terminal window
# Unregister (deletes the data!)
wsl --unregister Ubuntu
# Reinstall
wsl --install -d Ubuntu
Exporting/importing a distribution
wsl --export produces a .tar archive holding the distribution's whole file system: installed packages, personal files, configuration. It is the backup mechanism provided as standard, and it serves as much to migrate to another machine as to move a distribution to another disk when C: fills up. On import, the second argument is the destination directory of the virtual disk, not a file: give an empty folder.
wsl --list --verbose shows the distribution in version 2
Working network access (sudo apt update succeeded in step 5)
.wslconfig created to limit RAM (optional)
Key points
These points sum up what to keep in mind to use WSL2 day to day, from
installation to backup.
Concept
Key point
WSL2
A real Linux kernel in a lightweight virtual machine, not an emulation
Installation
wsl --install does everything in one command, then the PC restarts
First launch
User created, password invisible as you type it, packages updated with sudo apt update && sudo apt upgrade -y
Files
Work in your app's native file system
Resources
Limit RAM through .wslconfig if needed
Graphical applications
WSLg, on Windows 11 or Windows 10 build 19044+
VS Code
WSL extension to develop natively
Backup
wsl --export before any risky operation
Swipe to see more
Knowledge check
Check that the essentials of this guide stuck. The questions only cover
what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
6 questions
6 min
70% to pass
How it works
The timer starts when you click Start
Multiple choice, true/false and short answer questions
You can move between questions
Detailed results are shown at the end
Starts the quiz and the timer
⏱️--:--
0 / 6
Review
(0/0)
--:--
0%
0Correct
0To review
0:00Time
-Level
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Continue the course: Open a terminal and understand the prompt
A new full quiz with random questions
Work again only on the questions you missed
FAQ: frequently asked questions
These questions come up often after a first installation, and they cover
points the guide handles in different places: the choice between WSL1 and
WSL2, access to Windows files from Linux and the use of Docker in the
distribution.
WSL 2 (Windows Subsystem for Linux 2) is a compatibility layer that runs a complete Linux environment directly on Windows, without a traditional virtual machine.
Architecture
┌─────────────────────────────────┐
│ Linux applications │
├─────────────────────────────────┤
│ Linux kernel (real) │
├─────────────────────────────────┤
│ Lightweight virtual machine │
├─────────────────────────────────┤
│ Windows (Hyper-V) │
└─────────────────────────────────┘
Key features
Real Linux kernel: full compatibility with Linux applications
Performance: fast access to the Linux file system
Windows integration: access to Windows files from Linux and vice versa
GUI applications: support for Linux graphical applications on Windows 11 and Windows 10 build 19044+
Use cases
Development: a Linux environment without leaving Windows
DevOps: Docker, Ansible, Terraform on Windows
Training: learn Linux without dual-boot
WSL 1 and WSL 2 use fundamentally different architectures.
Comparison
Aspect
WSL 1
WSL 2
Architecture
Translation layer (syscalls)
Real Linux kernel in a lightweight VM
Compatibility
Partial (system call translation)
Complete (real Linux kernel)
Linux FS performance
Slow
Fast (native)
Windows FS performance
Fast
Slower (9P protocol)
Memory
Shared with Windows
VM with dynamic allocation
GUI applications
No
Yes (Windows 11, Windows 10 build 19044+)
When to choose WSL 1?
Projects stored on the Windows disk (/mnt/c/)
Limited memory resources
When to choose WSL 2? (recommended)
Linux development: compiling, testing
Containers: Docker, Podman
GUI applications: VS Code Remote, GIMP
Maximum compatibility: every Linux tool
Command to change version
# Switch a distribution to WSL 2
wsl --set-version Ubuntu 2
# Make WSL 2 the default
wsl --set-default-version 2
Hardware virtualisation (Intel VT-x or AMD-V) is mandatory for WSL 2.
Method 1: Task Manager (simple)
Open it with Ctrl + Shift + Esc
Performance tab → CPU
Look for the Virtualization line
Value
Meaning
Enabled
Ready for WSL 2
Disabled
Turn it on in the BIOS
Method 2: PowerShell (detailed)
# Check Hyper-V support
Get-ComputerInfo | Select-Object HyperV*
# Expected result
HyperVisorPresent : True
HyperVRequirementVirtualizationFirmwareEnabled : True
Method 3: systeminfo command
systeminfo | Select-String "Hyper-V"
# Expected result: every line set to "Yes"
Hyper-V Requirements: Yes
If virtualisation is disabled
You must turn it on in your machine's BIOS/UEFI (see the next question).
Turning it on depends on your computer's brand and on the processor type (Intel or AMD).
Step 1: Enter the BIOS/UEFI
Brand
Key(s) at startup
ASUS
F2 or DEL
Acer
F2 or DEL
Dell
F2 or F12
HP
ESC or F10
Lenovo
F2 or F1 (ThinkPad: Enter + F1)
MSI
DEL
Samsung
F2
Step 2: Find the virtualisation option
Processor
Option name
Intel
Intel Virtualization Technology (VT-x)
AMD
AMD-V or SVM Mode
Possible locations:
Advanced Settings → CPU Configuration
Security → Virtualization
BIOS Features → Intel VT-x
Step 3: Turn it on and save
Set the value to Enabled
Press F10 (Save & Exit)
Restart the PC
Check after the restart
# Must return "True"
(Get-CimInstance Win32_Processor).VirtualizationFirmwareEnabled
WSL 2 installs with a single command on Windows 10 version 2004+.
Quick installation (recommended)
# Open PowerShell as Administrator
# Install WSL + Ubuntu by default
wsl --install
This command:
Turns on the required Windows features
Downloads the WSL 2 Linux kernel
Installs Ubuntu from the Microsoft Store
Choose another distribution
# List the available distributions
wsl --list --online
# Install a specific distribution
wsl --install -d Debian
wsl --install -d kali-linux
wsl --install -d Ubuntu-22.04
Popular distributions
Distribution
Command
Use
Ubuntu
wsl --install -d Ubuntu
General, development
Debian
wsl --install -d Debian
Servers, stability
Kali Linux
wsl --install -d kali-linux
Security, pentesting
Arch Linux
Manual installation
Advanced users
AlmaLinux
wsl --install -d AlmaLinux-9
RHEL alternative
After installation
# First launch: create a user
wsl
# Enter a user name and password
# Update the packages
sudo apt update && sudo apt upgrade -y
For environments without Internet access or without the Microsoft Store (Windows Server, LTSC).
# Stop WSL to apply
wsl --shutdown
# Start again
wsl
Graphical interface (Windows 11)
Recent WSL versions provide the WSL Settings application, opened from the Start menu: Microsoft recommends using it rather than editing the file by hand.
WSLg (Windows Subsystem for Linux GUI) runs Linux applications with a graphical interface on Windows 11 or Windows 10 build 19044+.
Prerequisites
Item
Required
Windows
Windows 11 or Windows 10 build 19044+
WSL
Recent version (wsl --update)
GPU driver
Compatible Intel/AMD/NVIDIA
Check support
# Update WSL
wsl --update
# Check the version
wsl --version
# The WSLg version must appear
In Settings → General: turn on Use WSL 2 based engine
In Settings → Resources → WSL Integration: turn on your distributions
Check
# From WSL
docker --version
docker info
Alternative: native Docker Engine in WSL
To avoid Docker Desktop (licence):Install Docker Engine from the official APT repository described in the Docker documentation (Install Docker Engine on Ubuntu), never with a script downloaded and run blindly, then:
# Add the user to the docker group
sudo usermod -aG docker $USER
# Start the service and enable it at boot (systemd turned on in /etc/wsl.conf)
sudo systemctl enable --now docker
Best performance
Tip
Explanation
Store projects in WSL
/home/user/projects/, not /mnt/c/
Use named volumes
Avoid bind mounts to Windows
Allocate enough RAM
.wslconfig with memory=8GB at least
docker-compose example in WSL
# Go to the Linux folder (not /mnt/c/)
cd ~/projects/my-app
# Start the services
docker compose up -d
# Access from Windows
# http://localhost:3000 (automatic port forwarding)
WSL gives two-way access between the Windows and Linux file systems.
Access Windows from WSL
# Windows drives are mounted under /mnt/
ls /mnt/c/Users/
cd /mnt/c/Users/MyName/Documents
# Example: copy a file
cp /mnt/c/Users/MyName/file.txt ~/
Access WSL from Windows
# Through File Explorer
\\wsl$\Ubuntu\home\myuser
# Or from the address bar
\\wsl.localhost\Ubuntu
Performance best practices
Situation
Recommendation
Linux dev project
Store it in ~/projects/ (native WSL)
Shared files
Use /mnt/c/ occasionally
Git clone
Always clone on the Linux side
npm/pip install
Run from the Linux FS
Open VS Code from WSL
# Go to the project folder
cd ~/projects/my-app
# Open VS Code with Remote-WSL
code .
Copy between systems
# Windows → WSL
cp /mnt/c/Users/MyName/Downloads/file.zip ~/
# WSL → Windows
cp ~/report.pdf /mnt/c/Users/MyName/Documents/
# With Windows Explorer
explorer.exe . # Opens the current folder in Explorer
Performance
Access to the Linux file system from WSL 2 is the fastest; crossing the boundary, from Windows to WSL or from WSL to /mnt/c/, goes through a network protocol and costs much more.Golden rule: keep your projects in the file system where you work the most.
Here are the frequent problems and their solutions.
Error: "WSL 2 requires an update to its kernel component"
# Update WSL and its kernel
wsl --update
Error: "The virtual machine could not be started"
# Check that the Virtual Machine Platform is on
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all
# Restart
Restart-Computer
To set DNS yourself, first turn off automatic generation in /etc/wsl.conf ([network] section, generateResolvConf=false), run wsl --shutdown from Windows, then write your own /etc/resolv.conf. Without this step, WSL rewrites the file at the next start.
Reset a distribution
# Export important data first
wsl --export Ubuntu ubuntu-backup.tar
# Uninstall
wsl --unregister Ubuntu
# Reinstall
wsl --install -d Ubuntu
# Restore if needed
wsl --import Ubuntu C:\WSL\Ubuntu ubuntu-backup.tar
Diagnostic commands
# WSL status
wsl --status
# List distributions
wsl --list --verbose
# Stop every instance
wsl --shutdown
# Update WSL
wsl --update
# Check the version
wsl --version