Setting Up WSL 2 on Windows 11
- Prerequisites**
- OS Requirement: Windows 10 version 1903+ (Build 18362+) or Windows 11
- Virtualization: Must be enabled in BIOS/UEFI
- Permissions: Administrator access is required
Run these in elevated PowerShell:
Code:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
2. Download and Install the Latest WSL 2 Kernel Package
- Visit Manual installation steps for older versions of WSL
- Run the installer and follow the prompts
In an elevated PowerShell session, execute:
Code:
wsl --set-default-version 2
4. Install a Linux Distribution
- Open Microsoft Store
- Search for Ubuntu, Debian, Fedora, etc.
- Click Get and then Install
- Launch the distro from the Start menu, and create a UNIX user account
View installed distros and their WSL version:
Code:
wsl --list --verbose
Code:
wsl --set-version <DistroName> 2
WSL 2 on Windows 11 supports GUI applications out of the box:
Code:
# Inside your distro’s shell
sudo apt update && sudo apt install gedit
gedit
7. Integrating Visual Studio Code
- Install VS Code on Windows
- In VS Code Marketplace, install the “Remote – WSL” extension
- Open your project folder inside WSL with Remote‑WSL: New Window
- Edit files, launch terminals, and debug inside the Linux environment
Create a [.wslconfig] file in [%USERPROFILE%] to customize system resources:
Code:
[wsl2]
memory=4GB
processors=2
9. Advanced Tips
- GPU Compute: Enable CUDA by installing NVIDIA drivers for WSL
- Docker Desktop: Use Docker’s WSL 2 backend for native container workflows
- File Performance: Store code in the Linux filesystem (
/home
) rather than under/mnt/c
for faster I/O
- If
wsl --status
shows mismatched versions, run:
Code:wsl --update
- For network issues, reset:
Code:netsh winsock reset
- If GUI apps fail to launch, ensure the Windows Feature “Graphics Tools” is enabled
WSL 2 on Windows 11 bridges Windows and Linux in a single workflow. Whether you’re compiling code, running web servers, or experimenting with AI frameworks, this powerful subsystem makes Windows 11 a true all‑in‑one developer platform.
Last edited: