Azure Zero to Hero: Day-27 | Make your Windows Laptop 10X Productive for DevOps and Cloud | WSL 2
Welcome to Day-27 of the Azure Zero to Hero series. In this chapter, guest expert George joins host Abhishek to explore a transformative productivity hack for Windows developers and DevOps engineers: WSL 2 (Windows Subsystem for Linux version 2). If you have ever felt restricted by operating system discrepancies—struggling with standard Windows Command Prompt (CMD) while trying to run UNIX shell scripts, Docker commands, SSH, or SCP utilities—WSL 2 bridges that gap entirely by bringing a full, native Linux kernel directly into your Windows environment without the overhead of heavy virtualization.
1. Why Do We Need WSL 2? (The Windows Developer Dilemma)
For years, cloud and DevOps engineers working primarily with Linux servers faced a steep workflow friction when using Windows laptops. Standard tools like CMD or PowerShell lacked native POSIX compliance, causing commands like ssh, scp, grep, and bash shell scripts to fail or require third-party emulation layers like Cygwin or Git Bash.
- The Cross-Platform Pain Point: Cloud-native tooling (Kubernetes, Docker, Terraform, Ansible) is built natively for Linux. Developing on Windows often led to path resolution bugs, line-ending mismatches (
CRLFvsLF), and performance bottlenecks. - The Traditional Virtualization Trap: Running a full Linux Virtual Machine (VM) via Hyper-V or VirtualBox consumed massive amounts of RAM, introduced complex network bridging configurations, and isolated the file system from the host operating system.
- The WSL 2 Solution: Instead of running an emulated layer or a heavyweight VM, WSL 2 embeds an actual lightweight Linux kernel directly inside Windows, allowing developers to run unmodified Linux binaries, Docker containers, and IDE integrations with near-metal performance.
2. Core Mental Model: Windows & Linux Living Together
Think of WSL 2 not as a traditional virtual machine, but as a dual-citizenship architecture inside your operating system. The Windows host kernel and the lightweight WSL 2 Linux kernel run side-by-side managed by a streamlined Hyper-V architecture, sharing hardware resources dynamically.
Note: Unlike WSL 1—which translated Linux system calls into Windows system calls on the fly (causing slow disk I/O performance)—WSL 2 includes a real Linux kernel running in a lightweight utility VM. This yields massive file system performance and complete system call compatibility.
3. Prerequisites and System Requirements
Getting started with WSL 2 no longer requires enterprise-grade Windows Server licenses or complex manual feature configurations. It is accessible out of the box across modern Windows environments.
- Operating System Support: Fully optimized for Windows 11 and fully backward-compatible with Windows 10.
- Edition Flexibility: Works on Windows Home editions as well as Windows Pro; you do not need full Hyper-V management features enabled.
- Required Platform Feature: The underlying V2 Machine Platform must be enabled (though modern installations handle this automatically when installing from the Microsoft Store).
4. Installing and Managing Linux Distributions
Gone are the days of downloading heavy ISO files or configuring complex network adapters. Modern WSL management is streamlined through the Microsoft Store and the Windows command line.
Checking Current Distributions
To inspect which Linux distributions are currently installed and running on your machine, open PowerShell and execute:
wsl --list --verbose
# or short form:
wsl -l -v
Installing a New Distribution (e.g., Kali Linux or Ubuntu)
You can install distributions directly from the command line using the automated install switch:
wsl --install -d kali-linux
Once the installation completes, launching the distribution for the first time prompts you to create a UNIX username and password, setting up your isolated user environment instantly.
5. Modern Terminal Experience: Windows Terminal
Stop using legacy Command Prompt (CMD). To get the most out of WSL 2, George recommends using Windows Terminal, available from the Microsoft Store.
- Tabbed Interface: Run PowerShell, Azure CLI, Debian, and Kali Linux tabs side-by-side in a single window.
- Customization & Transparency: Easily adjust background colors, color schemes, and window transparency (holding
Ctrl + Shiftwhile scrolling with the mouse wheel). - Dropdown Flexibility: Quickly switch between different installed Linux distributions using the terminal dropdown menu.
6. Seamless Interoperability: Windows Explorer Meets Linux
One of the most powerful features of WSL 2 is its bidirectional file system sharing. Windows and Linux are no longer siloed islands.
- Accessing Linux from Windows Explorer: You can open Windows Explorer and navigate directly into your Linux file systems. Every installed distribution is exposed under the network path
\\wsl$\(e.g.,\\wsl$\kali-linux). - Accessing Windows from Linux: Inside your Linux terminal, your Windows host drives are automatically mounted under the
/mnt/directory:BASHcd /mnt/c # You are now directly inside your Windows C: Drive! - Shared Networking: Distributions share the network namespace of the Windows host by default, making local port forwarding and web development seamless.
7. Supercharging Docker Desktop with WSL 2 Integration
Running Docker containers on Windows used to require a resource-heavy Hyper-V virtual machine running Linux. WSL 2 changes the game entirely.
- Docker Engine Inside WSL 2: Docker Desktop runs its container engine directly on top of the WSL 2 backend, delivering lightning-fast container startup times and low CPU/memory overhead.
- WSL Integration Settings:
- Open Docker Desktop Settings.
- Navigate to Resources > WSL Integration.
- Toggle on integration for your preferred distributions (e.g., enabling it for
kali-linux). - Docker commands (
docker run,docker build,docker compose) executed inside your Linux terminal now communicate instantly with the Docker daemon.
8. GUI Applications & Advanced Workloads inside WSL 2
WSL 2 is not limited to headless command-line interfaces. Modern WSL supports GUI applications seamlessly.
- Running Graphical Apps: You can execute GUI-based Linux applications directly from the terminal (e.g., typing
firefoxinside a Kali Linux terminal launches the Linux build of Firefox natively on your Windows desktop). - Solving DevOps Community Roadblocks: Windows users who previously complained about missing
ssh,scp, or bash-specific deployment scripts in tutorials can now execute identical Linux commands without modification.
9. VS Code Integration: Developing Inside Linux
Visual Studio Code (vs code) bridges the gap between Windows and Linux development using remote extension architecture.
- Remote-WSL Extension: By installing the Dev Containers / Remote - WSL extensions in VS Code, you can open your workspace directly inside your Linux distribution.
- Environment Parity: Your code editor terminal runs bash inside WSL 2, ensuring that your local testing environment matches your cloud production environment ( parity).
Summary and Key Takeaways
- Native Linux Kernel: WSL 2 brings a true, lightweight Linux kernel to Windows, eliminating the performance penalties of older emulation layers and heavy VMs.
- Broad Compatibility: Runs smoothly on Windows 10 and 11, including Windows Home editions without requiring full Hyper-V.
- Simple CLI Setup: Easily install and manage multiple distributions (Ubuntu, Debian, Kali Linux) using simple commands like
wsl --install -d <distro>. - Windows Terminal: Ditch legacy CMD and use Windows Terminal for tabbed multitasking, customized themes, and adjustable transparency.
- Bidirectional File Sharing: Access Linux files seamlessly via Windows Explorer (
\\wsl$\) and access Windows drives inside Linux via/mnt/c. - Docker Desktop Acceleration: Leverage WSL 2 as the high-performance backend for Docker Desktop, avoiding resource-heavy Hyper-V VMs.
- GUI and Tooling Support: Run Linux GUI applications (like Firefox) and execute native UNIX commands (
ssh,scp,grep) directly on Windows. - VS Code Remote Development: Develop code inside your Linux environment using VS Code's Remote-WSL extensions for absolute environment consistency.