2CupsofJoe

WSL on Windows 11

WSL on Windows 11: A Developer’s Guide to Linux on Windows

Introduction

Windows Subsystem for Linux (WSL) has become a game-changer for developers, data scientists, and IT professionals who want to leverage Linux tools without leaving the Windows environment. Whether you're coding, managing servers, or experimenting with Linux-based workflows, WSL offers a seamless bridge between the two operating systems. In this guide, I’ll walk you through installing WSL on Windows 11 in the simplest way possible.

Why Use WSL?

Step-by-Step Installation Guide

Step 1: Enable WSL

Microsoft has made it incredibly easy to install WSL on Windows 11 with a single command.

  1. Open PowerShell as Administrator (search for "PowerShell" in the Start menu, then right-click and select Run as administrator).

  2. Run the following command:

    wsl --install
    

    This command will:

    • Enable the required Windows features
    • Download and install the latest WSL kernel
    • Install Ubuntu as the default Linux distribution
  3. Restart your computer when prompted.

Step 2: Verify the Installation

Once your computer restarts, open PowerShell or Command Prompt and type:

wsl --list --verbose

This will display a list of installed Linux distributions and their current state.

Step 3: Choose or Install a Different Linux Distribution

By default, Ubuntu is installed, but you can install other distributions like Debian, Kali Linux, or openSUSE. To see available distributions, run:

wsl --list --online

To install a different one, use:

wsl.exe --install <DistributionName>

For example, to install Ubuntu:

wsl.exe --install Ubuntu

Step 4: Set WSL Version (WSL 1 vs. WSL 2)

WSL 2 is the latest version and offers better performance and full system call compatibility. To ensure you're using WSL 2, run:

wsl --set-version <DistributionName> 2

For example:

wsl --set-version Ubuntu 2

To make WSL 2 the default for future installations:

wsl --set-default-version 2

Step 5: Running and Using WSL

Once installed, you can launch WSL in several ways:

Step 6: Update and Customize Your WSL Environment

After installation, update your Linux distribution:

sudo apt update && sudo apt upgrade -y

You can also install essential tools like Git, Node.js, Python, and Docker within your WSL instance.

Bonus: Integrating WSL with VS Code

For an even better development experience, install the Remote - WSL extension in Visual Studio Code to seamlessly work on Linux files within Windows.

  1. Open VS Code.
  2. Install the "Remote - WSL" extension.
  3. Open WSL by pressing Ctrl+Shift+P and selecting Remote-WSL: New Window.

Conclusion

With WSL on Windows 11, you get the best of both worlds: the versatility of Linux and the familiarity of Windows. Whether you're a seasoned developer or just getting started, WSL is a must-have tool for modern development workflows. Try it out, customize it to your liking, and level up your productivity!

Have thoughts or questions? Drop them in the comments!