WSL2 Introduction - How to Use Linux on Windows
What you'll be able to do
- Set up a Linux environment on Windows using WSL2
- Understand how WSL2 differs from a virtual machine
Prerequisites (read these first)
What is WSL2?
WSL2 (Windows Subsystem for Linux 2) lets you run a full Linux environment directly on Windows. You don't set up a virtual machine (software that runs one PC inside another) or a dual boot. It ships with Windows 10 (version 2004+) and Windows 11.
Unlike WSL1, WSL2 includes a real Linux kernelThe core program of an OS. It bridges hardware and software. — the core part of the OS. That is why 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 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 shellAn interactive program that reads the commands you type and runs them. 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. You also need virtualization (VT-x / AMD-V) turned on in the BIOS/UEFI — the setup screen you open while the PC boots. UEFI is the newer generation of 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 on, open Task Manager with Ctrl+Shift+Esc. Go to Performance → CPU and 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 PromptA symbol (like $ or #) shown when the shell is waiting for your input. 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 here. Once that is done, your Linux environment is ready.
The password you set here is required whenever you run sudo — the command that runs one command as the administrator. Write it down somewhere safe.
Installing a specific distribution
You can pick your own distribution — a bundle of Linux itself plus its packaged software, often shortened to "distro." List what is available first:
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 and the most documentation. It also ships with apt, the package managerA tool that installs and updates software for you in one place. that installs, updates, and removes software for you.
| 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 (Long Term Support). You get a five-year support period and the widest documentation coverage.
How do I start using Linux on WSL2?
There are two ways to launch WSL2. Search for "Ubuntu" in the Start menu, or type wsl in any PowerShell or 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/ — your C: drive appears at /mnt/c/. Going the other way, Windows reaches Linux files through \\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 directoryA container that organizes files. Same idea as a "folder" on Windows or macOS. in File Explorer. You can also type \\wsl$\Ubuntu\home\username directly in the File Explorer address bar.
Keep your working files inside the Linux home directory (/home/username/) rather than on the Windows filesystem (/mnt/c/...). Reads and writes that cross the OS boundary are much slower.
Editing Linux files in VS Code
Install the "Remote - WSL" extension in VS Code — an extension is an add-on that bolts extra features onto the editor. 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 and enter the BIOS/UEFI setup screen (usually F2 or DEL). Turn the virtualization option on there.
wsl --install fails on older Windows 10
On Windows 10 versions 1903–2004, you may need to turn the components on by hand:
# 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 install the WSL2 Linux kernel update package from Microsoft. After that, set WSL2 as the 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.