Windows Guides
Install WSL 2

Installing WSL 2 with Ubuntu

Introduction

Windows Subsystem for Linux (WSL) allows you to run a Linux distribution alongside your Windows 10/11 environment. WSL 2, the latest version, provides improved performance and full system call compatibility. In this guide, we will walk you through the process of installing WSL 2 and setting up Ubuntu as your Linux distribution.

Prerequisites

Before you begin, ensure you have the following:

  • Windows 10/11 installed on your PC.
  • Administrative privileges to enable required features and install components.
  • Virtualization enabled in your system's BIOS/UEFI settings.
  • An internet connection to download the necessary files.

Step-by-Step Guide

Enable Virtualization

First, you need to ensure that virtualization is enabled in your system's BIOS/UEFI settings.

  1. Restart your computer and enter the BIOS/UEFI setup. This is usually done by pressing a key like F2, F10, Delete, or Esc during startup. The exact key varies by manufacturer. When in doubt pressing all of them has never failed me.

  2. Once in the BIOS/UEFI setup, look for virtualization settings. These are often found under Advanced, CPU Configuration, or a similar section.

  3. Enable virtualization. This setting may be labeled as Intel VT-x, Intel Virtualization Technology, AMD-V, or SVM Mode.

  4. Save your changes and exit the BIOS/UEFI setup. Your computer will restart.

Enable WSL

With virtualization enabled, you can now enable WSL on your Windows 10/11 system.

  1. Open PowerShell as an administrator. You can do this by right-clicking the Start button and selecting Terminal (Admin).

  2. Enter the following command to enable WSL:

    wsl --install

    This command will enable WSL, install the latest WSL 2 Linux kernel, and set WSL 2 as the default version.

Install Ubuntu

With WSL enabled, the next step is to install Ubuntu.

  1. Open Microsoft Store from the Start menu.

  2. In the search bar, type Ubuntu and select the version you prefer (e.g., Ubuntu 20.04 LTS).

  3. Click the Install button. The installation process may take a few minutes.

  4. Once installed, click Launch to start Ubuntu. You will be prompted to create a new user account and password for your Ubuntu environment.

💡

You can choose from various other Linux distributions available in the Microsoft Store, such as Debian, openSUSE, Kali Linux, and more (Microsoft Learn) (opens in a new tab) (Winaero) (opens in a new tab).

Verify Installation

To ensure everything is set up correctly, you can verify the installation.

  1. Open PowerShell or Windows Terminal.

  2. Enter the following command to check the WSL version:

    wsl --list --verbose

    You should see Ubuntu listed with version 2.

Update and Upgrade Ubuntu

After installation, it's a good idea to update and upgrade your Ubuntu packages.

  1. In your Ubuntu terminal, run the following commands:

    sudo apt update
    sudo apt upgrade

    Follow the prompts to complete the updates.

Troubleshooting

Outdated Kernel Issues

If you encounter issues where the installation is not using WSL 2, it might be due to an outdated kernel. Follow these steps to resolve it:

  1. Check WSL Version: Ensure that WSL 2 is set as the default version.
wsl --set-default-version 2
  1. Update WSL Kernel: Download and install the latest WSL 2 Linux kernel update package from the Microsoft WSL 2 kernel update page (opens in a new tab).

  2. Set Distribution to WSL 2: If you have already installed Ubuntu and it's not using WSL 2, set the version explicitly.

    wsl --set-version Ubuntu-20.04 2
    💡

    Replace Ubuntu-20.04 with the appropriate distribution name if you are using a different version.

  3. Restart WSL: Restart the WSL to apply changes.

    wsl --shutdown

    Then, relaunch your Ubuntu terminal.

  4. Verify Kernel Version: Check the kernel version inside the Ubuntu terminal to ensure it reflects WSL 2.

    uname -r

    You should see a kernel version starting with 4.19 or higher, indicating WSL 2.

If these steps don't resolve the issue, ensure your Windows 11 installation is up to date, as updates may include important fixes and improvements for WSL.

Conclusion

Congratulations! You have successfully installed WSL 2 with Ubuntu on your Windows 10/11 machine. You can now enjoy the benefits of both Windows and Linux in a seamless environment. WSL 2 provides a powerful toolset for developers, sysadmins, and IT enthusiasts, allowing you to leverage Linux capabilities directly from your Windows system.

Feel free to explore and customize your Ubuntu environment, install additional packages, and integrate it with your existing Windows workflow.

Happy coding!