WSL2 Introduction - How to Use Linux on Windows
What is WSL2?
WSL2 (Windows Subsystem for Linux 2) lets you run a full Linux environment directly on Windows — no virtual machine, no dual boot required. It ships with Windows 10 (version 2004+) and Windows 11.
Unlike WSL1, WSL2 includes a real Linux kernel, which means Docker, systemd, and virtually all Linux tools work as expected. For anyone learning Linux on a Windows PC, WSL2 is the most practical starting point available today.
What you can do with WSL2
- Run Ubuntu, Debian, Fedora, and other Linux distros on Windows
- Run Docker containers natively
- Set up Python, Node.js, and other development environments
- Write and run shell scripts
- Edit Linux files directly in VS Code via Remote - WSL
What are the WSL2 system requirements?
You need Windows 10 version 2004 (build 19041) or later, or Windows 11, with virtualization (VT-x / AMD-V) enabled in your BIOS.
| Requirement | Minimum |
|---|---|
| OS | Windows 10 version 2004 (build 19041+) or Windows 11 |
| Architecture | x64 or ARM64 |
| Virtualization | Enabled in BIOS/UEFI |
Check your Windows version by running winver in the Run dialog (Win+R).
To verify virtualization is enabled, open Task Manager (Ctrl+Shift+Esc) → Performance → CPU → look for "Virtualization: Enabled".
How do I install WSL2?
On Windows 11 and Windows 10 (October 2021 Update or later), a single command installs WSL2 and Ubuntu together.
1. Open PowerShell or Command Prompt as Administrator
Right-click the Start button and select "Windows Terminal (Admin)" or search for "PowerShell" and run as Administrator.
2. Run the install command
wsl --install
Installing: Virtual Machine Platform Virtual Machine Platform has been installed. Installing: Windows Subsystem for Linux Windows Subsystem for Linux has been installed. Installing: Ubuntu Ubuntu has been installed. The requested operation is successful.
3. Restart your PC
After the restart, Ubuntu setup launches automatically. Set a username and password to complete the setup.
The password you set here is required whenever you run sudo commands. Write it down somewhere safe.
Installing a specific distribution
To see available distributions:
wsl --list --online
NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling Ubuntu-22.04 Ubuntu 22.04 LTS Ubuntu-24.04 Ubuntu 24.04 LTS ...
To install a specific one:
wsl --install -d Ubuntu-24.04
Verify the installation
wsl -l -v
NAME STATE VERSION * Ubuntu Running 2 Ubuntu-24.04 Stopped 2
The VERSION column should show 2 for WSL2.
Which Linux distribution should I choose?
For most users, Ubuntu is the right choice — it has the largest community, the most documentation, and the apt package manager makes installing tools straightforward.
| Distribution | Characteristics | Best for |
|---|---|---|
| Ubuntu | Large community, apt package manager | Beginners, general development |
| Debian | Lightweight, stability-focused | Users with server experience |
| Kali Linux | Security tool collection | Security learners |
| openSUSE | Enterprise-grade tools | Corporate/enterprise workflows |
When in doubt, pick Ubuntu LTS. Five-year support period, maximum documentation coverage.
How do I start using Linux on WSL2?
Launch WSL2 by searching for "Ubuntu" in the Start menu, or type wsl in any PowerShell/Command Prompt window.
wsl
Once inside the Linux shell, you can run standard Linux commands:
# Show current directory pwd
/home/username
# List files with details ls -la
# Update package lists (always run after initial setup) sudo apt update && sudo apt upgrade -y
Shutting down WSL2
# Terminate a specific distro wsl --terminate Ubuntu # Shut down all WSL instances wsl --shutdown
How do I share files between Windows and Linux?
WSL2 mounts Windows drives under /mnt/ (e.g., C: drive at /mnt/c/), and Windows can access Linux files via \\wsl$\Ubuntu in File Explorer.
Accessing Windows files from WSL2
# Browse C: drive ls /mnt/c/Users/ # Copy a file to Windows Documents cp myfile.txt /mnt/c/Users/username/Documents/
Opening Linux files in Windows File Explorer
From inside the Linux shell, run:
explorer.exe .
This opens the current Linux directory in File Explorer. You can also type \\wsl$\Ubuntu\home\username directly in the File Explorer address bar.
For best performance, keep your working files inside the Linux home directory (/home/username/) rather than on the Windows filesystem (/mnt/c/...). Cross-OS file I/O is significantly slower.
Editing Linux files in VS Code
Install the "Remote - WSL" extension in VS Code, then run this from your WSL2 shell:
code .
VS Code opens with full access to the Linux filesystem, terminal, and extensions running inside Linux.
How do I fix common WSL2 errors?
"Virtualization is not enabled" error
Cause: VT-x / AMD-V is disabled in BIOS.
Fix: Restart your PC, enter the BIOS/UEFI setup screen (usually F2 or DEL), and enable the virtualization option.
wsl --install fails on older Windows 10
On Windows 10 versions 1903–2004, you may need to enable components manually:
# Run in PowerShell (Admin) dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart, then download and install the WSL2 Linux kernel update package from Microsoft, then set WSL2 as default:
wsl --set-default-version 2
Error 0x80370102: WslRegisterDistribution failed
Cause: Hyper-V or Virtual Machine Platform is not enabled.
Fix:
# Run in PowerShell (Admin) dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart and try again.
Forgotten password
# In PowerShell (Admin) — launch distro as root ubuntu config --default-user root # Inside WSL2, reset the password passwd username # Restore the default user ubuntu config --default-user username
Replace ubuntu with your actual distro command name (e.g., ubuntu2404) if needed.