Master WSL on Windows 11 for fast, flexible development
This deep dive explains how to install, configure, and scale WSL 2 so your workflows feel native on both Windows and Linux. Pair the stability of Windows with the power of the Linux CLI, GPU acceleration, and cloud tooling.
- ✓Install a complete Linux userland in minutes—no dual boot, repartitioning, or complex virtualization required.
- ✓Share files, networking, and tooling seamlessly between Windows 11 and your favorite Linux distributions.
- ✓Accelerate AI, web, and cloud workflows with GPU, USB, and IDE integrations that feel native on both sides.
Tip: pair this workflow with the .wslconfig file to fine-tune CPU, memory, and swap for laptops and dev workstations.
Navigate this guide
Jump directly to the topics you need. Every anchor links to a detailed section that expands on Linux workflows inside WSL.
Why WSL matters
Explore the four pillars that blend Windows convenience with Linux fidelity.
Choose your Linux distro
Compare Ubuntu, Debian, Fedora, and openSUSE profiles for WSL workloads.
Install & configure WSL
Follow a hardened step-by-step installer playbook with repeatable commands.
Manage distros like a pro
Use wsl.exe commands to list, convert, export, and terminate distros cleanly.
Daily Linux operations
Standardize package updates, installs, and cleanups across major distros.
Desktop environments in WSL
Install GNOME, KDE, or Xfce over WSLg for full-fledged Linux desktops.
Integrate tooling
Wire up editors, containers, and automation runners to your WSL projects.
Performance tuning
Optimize storage layout, resource usage, and subsystem lifecycle.
Automate everything
Script onboarding, updates, backups, and compliance tasks for teams.
Troubleshoot Linux behavior
Diagnose systemd, clock drift, disk growth, and NTFS performance issues.
FAQ
Get quick answers about systemd services, SSH key sharing, and Docker usage.
Curated resources
Jump to official docs, release notes, templates, and community projects.
Why WSL 2 is a powerhouse for developers
WSL bridges Windows and Linux so you can choose the best tool for each job without leaving your flow. These pillars show how it balances fidelity, convenience, and governance for modern teams.
Linux-first fidelity
WSL 2 runs a Microsoft-maintained Linux kernel in a lightweight utility VM for near-native performance.
- Full system call support means Docker, Podman, Kubernetes, and build tools behave exactly as they do on bare metal.
- Kernel updates are delivered through Windows Update, giving you the latest security patches automatically.
Tight Windows integration
Mix Windows productivity with Linux command-line prowess.
- Access your Windows filesystem at /mnt/c while keeping Linux performance for large projects in /home.
- Launch Linux binaries from PowerShell and Windows apps from Bash with shared environment variables.
Graphics & device support
WSLg and forwarders bridge hardware capabilities between environments.
- Run GUI apps like GNOME Builder, DataGrip, or Firefox with GPU acceleration directly from WSL.
- Attach USB devices, serial ports, and GPUs using wsl --mount and the latest CUDA/DirectML drivers.
Security & governance
Keep your dev boxes compliant without sacrificing speed.
- Isolate projects per distro, disable interop when you need stricter boundaries, and script teardown with one command.
- Use Microsoft Defender for Endpoint and Windows sandboxing features alongside Linux security tooling.
Choose the right Linux distro for WSL
Each distribution balances release cadence, package availability, and administrative tooling differently. Start with the profile that aligns with your workloads, then branch out for specialized stacks.
Ubuntu LTS
APTCanonical-supported distro with predictable releases and the richest community docs.
Best for: Teams that want stability, long-term support (5 years), and easy access to PPAs for language stacks.
- Enable the Partner repository when you need proprietary fonts or codecs.
- Use sudo apt install ubuntu-wsl to grab curated defaults tuned for WSL.
Debian Stable
APTMinimalist base with conservative updates and rock-solid reliability.
Best for: CI agents, automation scripts, or developers who value minimal changes between updates.
- Add backports when you need newer toolchains such as GCC or Clang.
- Pair with direnv and asdf to keep per-project tool versions isolated.
Fedora Kinoite / Workstation
DNFLeading-edge GNOME experience with SELinux and a fast cadence.
Best for: Frontier developers testing new compilers, GNOME tooling, or Wayland-first workflows.
- Install sudo dnf groupinstall "Development Tools" for build essentials.
- Use rpm-ostree for immutable deployments or when layering packages over Kinoite.
openSUSE Leap / Tumbleweed
ZypperYaST-powered control with both rolling and regular release options.
Best for: Ops teams that need Btrfs snapshots, transactional updates, and granular system administration.
- Pattern-based installs (sudo zypper in -t pattern devel_basis) accelerate language bootstrapping.
- Use snapper to snapshot before major changes; combine with wsl --export for belt-and-suspenders backups.
Install and configure WSL 2 step by step
Follow these steps to provision WSL 2 cleanly. Each command is safe to rerun and can be automated across organizations.
Enable required features
From an elevated PowerShell session, turn on virtualization and the Windows Subsystem for Linux components, then restart.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartInstall WSL with your preferred distro
Use the simplified installer to download the kernel, set WSL 2 as default, and grab Ubuntu, Debian, or another image in one go.
wsl --install -d UbuntuStay updated and tuned
Apply the latest kernel and set WSL 2 as your default version so new distros use the performant virtualization stack.
wsl --update
wsl --set-default-version 2Bootstrap the distro
Complete the Linux user setup, refresh packages, and install essential tooling from inside the distribution shell.
sudo apt update && sudo apt upgrade && sudo apt install build-essential git curl unzipNeed a visual walkthrough? Jump to the installation guide for screenshots and hardware prerequisites.
Manage distros like a pro
The wsl.exe CLI controls the lifecycle of each distribution. Combine these commands with scripts to keep projects tidy and reproducible.
wsl -l -v
List installed distributions with their version (WSL 1 or WSL 2) and current state.
wsl --set-version Ubuntu-24.04 2
Convert a distro to WSL 2 when you need full system call compatibility and better file I/O.
wsl --set-default Ubuntu-24.04
Choose the distribution that launches when you type wsl in Windows Terminal.
wsl --export Debian debian-backup.tar
Capture a snapshot you can version, store off-machine, or restore with wsl --import.
wsl --terminate Ubuntu-24.04
Gracefully shut down a running distro before freeing disk space or resizing the virtual disk.
Daily Linux operations playbook
Keep your distributions healthy with a predictable maintenance rhythm. Standardize package manager commands so teammates and automation know exactly what to run.
Ubuntu / Debian
Package manager: APT
sudo apt update && sudo apt upgrade
apt search <package>
sudo apt install <package>
sudo apt autoremove && sudo apt clean
Fedora
Package manager: DNF
sudo dnf upgrade --refresh
dnf search <package>
sudo dnf install <package>
sudo dnf autoremove
openSUSE
Package manager: Zypper
sudo zypper refresh && sudo zypper update
zypper search <package>
sudo zypper install <package>
sudo zypper packages --orphaned
Store these commands in a shared README.md or onboarding script so every new hire understands the expected hygiene tasks.
Desktop environments in WSLg
WSLg brings full Linux GUI support. These desktop recipes give you a polished workstation without leaving Windows. Pick the one that matches your workflow and hardware budget.
Ubuntu Desktop (GNOME)
Full GNOME Shell experience with WSLg support for windowed apps.
- sudo apt install ubuntu-desktop --no-install-recommends
- wsl --shutdown to restart the subsystem with new systemd targets.
- Use systemctl --user enable --now gnome-keyring-daemon.service for credential prompts.
KDE Plasma
Highly customizable Qt-based desktop, great for multi-monitor productivity.
- sudo apt install kde-plasma-desktop or sudo dnf groupinstall "KDE Plasma Workspaces"
- Install xdg-desktop-portal-kde to improve file dialogs and clipboard bridging.
- Set the QT_QPA_PLATFORMTHEME=qt5ct environment variable if theming looks inconsistent.
Xfce minimal desktop
Lightweight alternative for resource-constrained machines.
- sudo apt install xubuntu-desktop --no-install-recommends
- Disable screen lockers (light-locker-command -a) to avoid blank resume screens inside WSLg.
- Map Super key shortcuts via xfconf-query for quick launchers alongside Windows hotkeys.
Heads up: heavy desktop sessions can increase VRAM usage. Use wsl --shutdown after long GUI sessions to reclaim resources.
Integrate WSL with your tooling
WSL thrives when you pair it with modern editors, container runtimes, and automation workflows. Start with these integration patterns and tailor them to your stack.
Editor & IDE workflow
- Use VS Code with the Remote - WSL extension for Linux terminals, debugging, and IntelliSense from Windows.
- Neovim, JetBrains Gateway, and Fleet all support remote targets that point at your WSL workspace.
Container & cloud tooling
- Docker Desktop integrates with WSL 2 backends, letting Linux containers share the Windows networking stack.
- Podman, nerdctl, and kind work inside WSL with native cgroups and overlayfs support.
Graphics, AI, and data
- Access GPUs via NVIDIA CUDA on WSL, AMD ROCm, or DirectML for machine learning workloads.
- Run Jupyter, VS Code notebooks, or data visualization apps with hardware acceleration through WSLg.
Operational excellence
- Forward ports to Windows with wsl --port, or expose services to the LAN by binding to 0.0.0.0 inside the distro.
- Use Windows Task Scheduler or GitHub Actions runners to orchestrate scripts that target WSL environments.
Performance tuning & reliability
Optimize file placement
Keep active project files on the Linux side (~/projects) for the best git, npm, and compile speeds. Use /mnt/c only for quick asset sharing or when Windows-only tooling must access the data.
Control resource usage
Create a .wslconfig in your Windows user profile to pin CPU, memory, and swap allocations. This prevents runaway processes and keeps laptops cool during long builds.
Mindful shutdowns
Use wsl --shutdown or Windows Terminal’s “Close all tabs” to flush disks cleanly. Combine with bcdedit /set hypervisorlaunchtype off when you need to temporarily disable virtualization.
Automate everything
Treat WSL environments as disposable, reproducible dev shells. Automation keeps everyone aligned, whether you manage a team or personal projects.
One-command onboarding
- Publish a PowerShell profile snippet that installs WSL, your preferred distro image, configures git, and seeds dotfiles.
- Pair with cloud-init or Ansible inside the distro to bootstrap languages, SSH keys, and secrets managers.
Store Bootstrap scripts in a public GitHub Gist and reference them from your team handbook.
Scheduled maintenance
- Use schtasks or PowerShell scheduled jobs to run wsl --update nightly and apply apt security patches.
- Automate wsl --export backups to OneDrive, Azure Files, or an external disk for disaster recovery.
Tag exports with timestamps (wsl --export Ubuntu backup-%DATE%.tar) for simple retention policies.
Compliance & hardening
- Disable interop via /etc/wsl.conf (set interop=false) when policy requires strict separation between Windows and Linux.
- Mount encrypted VHDX files for sensitive projects and wipe them with wsl --unregister when the engagement ends.
Document the hardening checklist in your security wiki and version it alongside infrastructure-as-code.
Troubleshoot Linux behavior
When the Linux side of WSL misbehaves, use these diagnostics before rebuilding a distro. They capture the most common cross-OS friction points.
Systemd not starting?
Make sure your distro has systemd enabled in /etc/wsl.conf and that you are on WSL 2.
- Add [boot] systemd=true to /etc/wsl.conf and restart with wsl --shutdown.
- Verify with systemctl list-units --type=target --state=running.
Clock skew between Windows and Linux
Occasional suspend/resume cycles can desync the hardware clock inside the VM.
- Run sudo hwclock --hctosys or use timedatectl set-ntp true.
- Schedule wsl.exe --shutdown on resume events via Task Scheduler for clean sync.
High disk usage in ext4.vhdx
Large node_modules or Docker layers can bloat the virtual disk.
- Use sudo du -sh /* to spot growth hotspots.
- Compact the disk from Windows: wsl --shutdown && diskpart > select vdisk file=C:\Users\<you>\AppData\Local\Packages\...\ext4.vhdx > compact vdisk.
Slow filesystem access from /mnt/c
NTFS passthrough is convenient but slower for many small files.
- Clone repos into ~/projects and use git config --global core.autocrlf input.
- Leverage [automount] options in /etc/wsl.conf to disable metadata translation when not required.
Frequently asked questions
Can I run systemd services automatically?
Yes. Enable systemd in /etc/wsl.conf, then use systemctl --user enable for per-user timers or systemctl enable for global services. WSL 2 honors dependencies on boot.
How do I share SSH keys securely?
Store keys in your Windows profile, then use ln -s /mnt/c/Users/<you>/.ssh ~/.ssh with chmod 600 permissions inside WSL. Consider Windows Hello backed FIDO2 keys for hardware security.
Is Docker Desktop required?
Not strictly. Native Docker Engine on WSL works with dockerd-rootless-setuptool.sh or dockerd, but Docker Desktop simplifies updates, networking, and credential helpers.
Curated resources
Keep this list handy as you explore deeper capabilities, troubleshoot edge cases, or align a Windows fleet around WSL-based development.
WSL Documentation Hub
Official Microsoft docs covering installation, advanced management, WSLg, and troubleshooting topics.
WSL Release Notes
Track kernel updates, new features, and bug fixes delivered through Windows Update and the Store.
Windows Terminal
Customize profiles, GPU-accelerated rendering, and quake mode access to all your distros.
Dev Container Templates
Launch consistent developer environments by combining WSL with Dev Containers and VS Code.
Kernel & virtualization tuning
Fine-tune .wslconfig, memory usage, networking, and filesystem behavior for enterprise fleets.
Community projects & samples
Discover curated WSL distros, scripts, and dotfile setups maintained by the WSL community.