Mastering WSL 2: The Complete Guide to Running Linux on Windows

How to run Linux seamlessly on Windows without VMs or dual-boot.

OS & Platforms

Environment Setup

Dev Tools

Article Image

Introduction

For years, developers working on Windows faced challenges when needing Linux tools or environments. Virtual machines were heavy, dual-boot setups were inconvenient, and Docker often felt overkill for lightweight workflows.

Enter Windows Subsystem for Linux (WSL 2) — a powerful, lightweight way to run a real Linux kernel directly inside Windows, without the overhead of full virtualization.

This guide will walk you through everything you need to know about WSL 2: what it is, how to install it, best practices, advanced usage, and how it stacks up against virtual machines and dual-boot setups.


What Is WSL 2?

WSL (Windows Subsystem for Linux) is Microsoft’s compatibility layer that allows Linux binaries to run on Windows.

  • WSL 1: Translated Linux system calls into Windows equivalents. Fast, but incomplete.
  • WSL 2: Runs a full Linux kernel inside a lightweight virtual machine, providing nearly 100% Linux compatibility and faster file I/O.

With WSL 2, you can run tools like Docker, Git, Node.js, Python, or even graphical Linux apps natively on Windows.


Key Benefits of WSL 2

  1. Full Linux Kernel
    Unlike WSL 1, WSL 2 uses a complete Linux kernel, making it much more compatible with software.
  2. Performance Improvements
    File I/O performance is drastically better, especially when working inside the Linux filesystem.
  3. Seamless Integration with Windows
    You can access your Windows files from Linux at /mnt/c/, and your Linux files from Windows via File Explorer.
  4. Docker Support
    WSL 2 allows Docker Desktop to run Linux containers natively, without needing a heavy VM.
  5. GUI App Support
    With WSLg, you can run Linux graphical applications side by side with Windows apps.

Installing WSL 2

Microsoft has made WSL 2 installation much easier in Windows 10 and 11.

Step 1: Install WSL

Open PowerShell as Administrator and run:

wsl --install

This command will:

  • Enable required Windows features
  • Install the latest Linux kernel
  • Set WSL 2 as default
  • Install Ubuntu by default (you can choose others later)

Step 2: Check Installed Distros

wsl --list --verbose

You’ll see which distros are installed and whether they’re using WSL 1 or WSL 2.

Step 3: Set Default WSL Version

wsl --set-default-version 2

This ensures all future Linux distributions you install use WSL 2.

Step 4: Install Another Distribution (Optional)

For example, to install Debian:

wsl --install -d Debian

Everyday Usage

  • Launch your distro by typing its name in the Start Menu (e.g., "Ubuntu").
  • Update packages just like on Linux:
    sudo apt update && sudo apt upgrade -y
    
  • Access Windows files from Linux:
    cd /mnt/c/Users/YourName/Documents
    
  • Access Linux files from Windows:
    Open File Explorer and enter:
    \\wsl$\Ubuntu\
    

Advanced Features

  1. Running Docker
    Install Docker Desktop, enable WSL 2 integration, and containers will run directly in Linux.
  2. Custom Configuration
    Edit .wslconfig in your Windows user folder to tweak memory, processors, and swap file usage. Example:
    [wsl2]
    memory=4GB
    processors=2
    swap=2GB
    
  3. Graphical Linux Apps
    With WSLg (on Windows 11), you can run Linux GUI apps like Gedit, Firefox, or even GIMP seamlessly.

WSL 2 vs Virtual Machines vs Dual Boot

Before you commit to WSL 2, it helps to see how it compares to other popular approaches.

Feature

WSL 2

Virtual Machine

Dual Boot

Performance

Near-native for Linux CLI & dev tools

Slower (VM overhead)

Full native performance

Resource Usage

Lightweight, shares Windows kernel resources

Heavy (dedicated RAM/CPU)

Full access to hardware

Ease of Setup

Very easy (wsl --install)

Medium (install VM software + ISO)

Complex (partitioning, bootloader setup)

Compatibility

Almost full Linux kernel support

Full Linux kernel support

Full Linux kernel support

Switching OS

Instant (open Linux terminal in Windows)

Easy (switch VM window)

Requires reboot

Best For

Devs who want Linux tools inside Windows

Running complete Linux desktop/server environments

Dedicated Linux users needing full native performance

Takeaway:

  • Use WSL 2 if you need Linux tools but still work primarily in Windows.
  • Use a VM if you need a full Linux desktop alongside Windows.
  • Use dual boot if you’re doing heavy Linux-only workloads (gaming, kernel hacking, or full-time Linux use).

Final Thoughts

WSL 2 bridges the gap between Windows and Linux in a way that feels seamless. Whether you’re a web developer, data scientist, or DevOps engineer, WSL 2 can dramatically simplify your workflow.

No more juggling dual-boot setups or clunky VMs — with WSL 2, you get the best of both worlds.

2025

momo

Build By