How to Install WSL

Install Windows Subsystem for Linux

OS
How to Install WSL

Installing WSL on Windows via Terminal

Windows Subsystem for Linux (WSL) allows you to run a Linux environment directly on Windows without the overhead of a traditional virtual machine. This guide will walk you through installing WSL using the Windows Terminal or Command Prompt.

Prerequisites

  • Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11
  • Administrator privileges on your Windows machine
  • Internet connection for downloading Linux distributions

The easiest way to install WSL is using the new simplified command available in recent Windows versions.

Step 1: Open Terminal as Administrator

  1. Press Win + X and select “Windows Terminal (Admin)” or “Command Prompt (Admin)”
  2. Alternatively, search for “Terminal” in the Start menu, right-click, and select “Run as administrator”

Step 2: Install WSL

Run the following command to install WSL with the default Linux distribution (Ubuntu):

wsl --install

This command will: - Enable the required Windows features (WSL and Virtual Machine Platform) - Download and install the latest Linux kernel - Set WSL 2 as the default version - Download and install Ubuntu (default distribution)

Step 3: Restart Your Computer

After the installation completes, restart your computer when prompted.

Step 4: Complete Linux Setup

After reboot, Ubuntu will automatically launch and ask you to: - Create a username (can be different from your Windows username) - Set a password for your Linux user account

Method 2: Manual Installation

If you prefer more control over the installation process or the simple method doesn’t work:

Step 1: Enable WSL Feature

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

Step 2: Enable Virtual Machine Platform

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Step 3: Restart Your Computer

Restart Windows to complete the feature installation.

Step 4: Set WSL 2 as Default Version

wsl --set-default-version 2

Step 5: Install a Linux Distribution

List available distributions:

wsl --list --online

Install your preferred distribution (e.g., Ubuntu):

wsl --install -d Ubuntu

Available Linux Distributions

You can choose from several Linux distributions:

  • Ubuntu (default and recommended for beginners)
  • Debian
  • openSUSE Leap
  • Kali Linux
  • Alpine WSL
  • Oracle Linux

To install a specific distribution:

wsl --install -d <DistributionName>

Useful WSL Commands

After installation, here are some helpful commands to manage your WSL environment:

Check WSL Status

wsl --status

List Installed Distributions

wsl --list --verbose

Set Default Distribution

wsl --set-default <DistributionName>

Start a Specific Distribution

wsl -d <DistributionName>

Shutdown WSL

wsl --shutdown

Update WSL

wsl --update

Troubleshooting

Error: “WSL 2 requires an update to its kernel component”

Download and install the WSL2 Linux kernel update package from Microsoft’s official website.

Error: “Please enable the Virtual Machine Platform Windows feature”

Run this command as administrator:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Virtualization Not Enabled

Enable virtualization in your BIOS/UEFI settings. Look for options like: - Intel VT-x - AMD-V - Virtualization Technology

Next Steps

Once WSL is installed, you can:

  1. Access your Linux environment: Type wsl in any terminal or search for your Linux distribution in the Start menu
  2. Install packages: Use your distribution’s package manager (e.g., apt for Ubuntu)
  3. Access Windows files: Navigate to /mnt/c/ to access your C: drive
  4. Install development tools: Set up Git, Node.js, Python, Docker, and other development tools
  5. Use VS Code: Install the WSL extension for seamless development

Conclusion

WSL provides a powerful way to run Linux tools and applications on Windows. The installation process has been greatly simplified, making it easier than ever to get started with Linux development on Windows machines.

For more advanced configurations and troubleshooting, refer to the official Microsoft WSL documentation.