How to Enable WSL2 on Windows: A Beginner's Step-by-Step Guide

Are you interested in running Linux on your Windows machine? With Windows Subsystem for Linux (WSL2), you can run a full-fledged Linux kernel directly on Windows, allowing you to use Linux command-line tools, utilities, and applications. This guide will walk you through the process of enabling WSL2 on Windows, even if you’re a complete beginner. We’ll also cover the benefits of using WSL, how to add the Ubuntu distribution, and a tip section explaining the difference between WSL and WSL2.

What is WSL and Why Use It?

Windows Subsystem for Linux (WSL) is a compatibility layer that allows you to run Linux distributions natively on Windows without the need for a virtual machine or dual-booting. Here are some key benefits of using WSL:

  • Seamless Integration: WSL integrates directly with Windows, allowing you to use Linux commands alongside Windows applications. You can access Windows files from Linux and vice versa.
  • Development Flexibility: Many developers prefer Linux for its powerful command-line tools. WSL allows you to use these tools on a Windows machine, making it easier to develop cross-platform applications.
  • Efficient Resource Usage: Unlike traditional virtual machines, WSL uses fewer resources, as it doesn’t require a separate kernel to be loaded.

Step 1: Check System Requirements

Before enabling WSL2, ensure your system meets the following requirements:

  • Windows Version: You need to be running Windows 10 version 2004 or higher, or Windows 11.
  • 64-bit System: Your machine must be a 64-bit system.

To check your Windows version:

  1. Press Win + R to open the Run dialog box.
  2. Type winver and press Enter.
  3. A window will pop up showing your Windows version.

Step 2: Enable the Windows Subsystem for Linux (WSL)

WSL needs to be enabled on your system before you can use WSL2. Here’s how to do it:

  1. Open PowerShell as Administrator:
    • Click on the Start menu, search for “PowerShell,” right-click on it, and select “Run as administrator.”
  2. Run the Command to Enable WSL:
    • In the PowerShell window, type the following command and press Enter:
      dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
      
    • This command enables WSL on your system.

Step 3: Enable Virtual Machine Platform

WSL2 requires the Virtual Machine Platform feature to be enabled on your system:

  1. Enable the Virtual Machine Platform:

    • In the same PowerShell window, type the following command and press Enter:
      dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
      
  2. Restart Your Computer:

    • After running the above commands, restart your computer to apply the changes.

Step 4: Set WSL2 as the Default Version

Now, you need to set WSL2 as the default version of WSL:

  1. Set WSL2 as Default:
    • Open PowerShell as Administrator again and type the following command:
      wsl --set-default-version 2
      
    • This command ensures that any new Linux distributions you install will use WSL2.

Step 5: Install a Linux Distribution (Ubuntu)

With WSL2 enabled, you can now install a Linux distribution of your choice. Ubuntu is one of the most popular distributions for WSL. Here’s how to add it:

  1. Open the Microsoft Store:
    • Search for “Microsoft Store” in the Start menu and open it.
  2. Search for Ubuntu:
    • In the Microsoft Store, type “Ubuntu” in the search bar to find the official Ubuntu distribution.
  3. Install Ubuntu:
    • Click on the Ubuntu distribution and select “Get” to download and install it.
  4. Launch Ubuntu:
    • Once installed, you can launch Ubuntu from the Start menu. The first time you launch it, you’ll be prompted to create a username and password for your Ubuntu environment.

Step 6: Start Using Linux on Windows

Congratulations! You now have Linux running on your Windows machine using WSL2. You can open your Linux distribution from the Start menu anytime and start using Linux commands and tools.

Tip: Understanding the Difference Between WSL and WSL2

Here’s a quick comparison between WSL and WSL2 to help you understand which one to use:

  • WSL (Windows Subsystem for Linux 1):

    • How It Works: Translates Linux system calls into Windows system calls.
    • Performance: Slower for complex operations like Docker.
    • Compatibility: Limited compatibility with some Linux software.
  • WSL2 (Windows Subsystem for Linux 2):

    • How It Works: Runs a full Linux kernel in a lightweight virtual machine.
    • Performance: Faster and more efficient, especially for intensive tasks.
    • Compatibility: Full compatibility with all Linux software, including Docker.

Recommendation: If you’re just getting started, WSL2 is the better choice due to its improved performance and compatibility.

By following these steps and tips, you can easily set up WSL2 on your Windows machine, enabling you to run Linux distributions like Ubuntu seamlessly. Whether you’re a developer looking to use Linux tools or simply curious about Linux, WSL2 offers a powerful and resource-efficient way to experience Linux on Windows. Enjoy exploring and harnessing the power of both Windows and Linux!

JuniorIT.AI

Acquire the essential skills and knowledge to kickstart your career and set off on a new path in the age of AI.

Haicam Technologies © 2023
Powered by OpenAI & Stable Diffusion