Unleashing Linux on Windows: A Developer’s Guide to WSL2

Why WSL2 is a game-changer for professionals and students, and how you can get started today.

Hey there, fellow tech enthusiast! If you’re a developer, DevOps engineer, or an IT student working on a Windows machine, you’ve likely faced a familiar dilemma: you need the power and tooling of a Linux environment, but you don’t want to leave the comfort of your Windows OS. For years, the solution was clunky virtual machines or risky dual-boot setups.

Enter the Windows Subsystem for Linux 2 (WSL2).

Microsoft has been investing heavily in making Windows a first-class citizen for open-source development, and WSL2 is the crown jewel of that effort. It’s not just a tool; it’s a fundamental shift in how developers can work. In this guide, we’ll dive deep into what WSL2 is, compare it to traditional virtualization, weigh its pros and cons for both professionals and students, and walk you through a proper installation and setup.

What is WSL2, and Why Not Just Use a VM?

At its core, WSL2 allows you to run a genuine Linux environment—including most command-line tools, utilities, and applications—directly on Windows, unmodified, without the overhead of a traditional virtual machine (VM).

Unlike its predecessor (WSL1), which translated Linux system calls into Windows calls, WSL2 uses lightweight virtualization technology to run a full, real Linux kernel. This is the key difference.

So, why use it over a traditional VM like VirtualBox or VMware?

  1. Deep Integration: This is WSL2’s superpower. You can access your Windows files from within Linux (at /mnt/c/) and, more importantly, access your Linux files from Windows Explorer (just type \\wsl$ in the address bar). You can even run Windows executables (like code .) from your Linux shell and vice-versa. This seamless interoperability is something traditional VMs struggle with.
  2. Performance & Efficiency: WSL2 boots up in seconds. A full VM can take minutes and consumes a significant, fixed amount of RAM and CPU. WSL2 is far more lightweight, using fewer resources and dynamically allocating memory as needed.
  3. Workflow, Workflow, Workflow: With tools like VS Code’s “Remote – WSL” extension, you can write code in Windows while your terminal, debugger, and linters run in a Linux environment. It’s the best of both worlds, integrated into a single, cohesive workflow. For DevOps tasks, running docker, terraform, ansible, or bash scripts feels native, not emulated.

The Verdict: Pros and Cons

No tool is perfect. Let’s break down the advantages and disadvantages for two key groups.

For the IT Professional (Especially DevOps)

Pros:

  • Native Tooling: Run essential DevOps tools like Docker, Kubernetes (via Docker Desktop), Ansible, and Terraform natively with full Linux compatibility.
  • Superior Docker Experience: Docker Desktop’s WSL2 backend is incredibly fast and stable.
  • Scripting Consistency: Develop and test your bash or python scripts in the exact same environment they’ll run in on your production servers.
  • Seamless IDE Integration: VS Code and JetBrains IDEs have fantastic WSL2 integration.

Cons:

  • Complex Networking: Setting up complex network scenarios can be more difficult than with a traditional VM.
  • Limited Hardware Access: WSL2 doesn’t provide raw access to all hardware, which can be an issue for specific peripherals.
  • Systemd Was a Catch (But It’s Fixed!): Historically, the lack of systemd was a major drawback, but it is now officially supported, removing a significant barrier.
For the IT Student

Pros:

  • Low Barrier to Entry: Get a real Linux terminal on the Windows laptop you already own without partitioning drives or complex VM management.
  • Resource Friendly: Runs well even on non-powerful student laptops.
  • Real-World Ready: Learning Linux in WSL2 directly translates to skills needed in the industry.
  • It’s Free: No licensing costs for WSL2 or the most popular Linux distributions.

Cons:

  • Abstraction Can Hide Learning Opportunities: The “just works” nature might hide details of a full Linux installation (partitioning, drivers, etc.).
  • Not Ideal for Kernel-Level Courses: For deep kernel module development, a dedicated Linux installation (VM or bare metal) is better.

Getting Started: A Robust Installation Guide

Ready to jump in? This step-by-step guide ensures a correct and robust WSL2 setup.

Step 0: Prerequisites – Check Your System

Before anything else, let’s ensure your system is ready. WSL2 has specific version requirements.

  1. Press Win + R, type winver, and press Enter.
  2. Check your Windows version and build number. You need:
    • For x64 systems: Version 1903 or higher, with Build 18362 or higher.
    • For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.

If your system is older, you must update Windows before proceeding.

Step 1: Enable Required Windows Features

Now, we’ll enable the two core components for WSL2. Open PowerShell as an Administrator (right-click the Start Menu and select “Windows PowerShell (Admin)”) and run these two commands, one after the other:

# Enables the Windows Subsystem for Linux feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

# Enables the Virtual Machine Platform feature, essential for WSL2
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Important: After running both commands, restart your computer to apply the changes.

Step 2: Set WSL2 as the Default Version

This is a crucial step to ensure you’re using the new, more powerful version of WSL. Open PowerShell as an Administrator again and run:

wsl --set-default-version 2

This command tells Windows that any new Linux distribution you install should use the WSL2 architecture.

Step 3: Install Your Linux Distribution

With the foundation in place, it’s time to install Linux.

1. First, see what distributions are available by running this in PowerShell:

wsl --list --online

2. For beginners and general use, we strongly recommend Ubuntu 24.04 LTS. It’s stable, widely supported, and most online tutorials use it. To install it, run:

wsl --install -d Ubuntu-24.04

This will download and install Ubuntu. The process may take a few minutes.

Step 4: Verify Your Installation

Let’s confirm everything is working as expected. In PowerShell, run:

wsl -l -v

The output should show your installed distribution (e.g., Ubuntu-24.04), its state as “Running” or “Stopped”, and, most importantly, the VERSION number as 2. If it shows version 1, something went wrong in the previous steps.

Step 5: Final Setup – User and System Update

  1. Launch your new distribution from the Start Menu (e.g., click on the “Ubuntu 24.04” icon).
  2. On the first launch, it will ask you to create a UNIX username and password. This is your primary user inside Linux and is separate from your Windows login.
  3. Once you’re at the command prompt (username@hostname:~$), the first and most important thing to do is update your system. Run the following command:
sudo apt update && sudo apt upgrade -y

This ensures all your software packages are up-to-date and secure.

Conclusion

WSL2 brilliantly bridges the gap between Windows and Linux, creating a powerful, integrated, and efficient development environment. For the DevOps professional, it streamlines workflows and provides native access to essential tools. For the IT student, it’s an accessible and resource-friendly gateway to mastering Linux.

By removing the friction of traditional virtualization, WSL2 empowers you to focus on what truly matters: learning, building, and deploying great software. So go ahead, follow the guide, and unlock a new world of possibilities on your Windows machine.