How to Install Ubuntu on WSL 2: A Comprehensive Guide

TIKAM CHAND
TIKAM CHAND

21 May 2025

How ToUbuntu

Unlock the power of Ubuntu within your Windows environment using Windows Subsystem for Linux 2 (WSL 2). This guide provides step-by-step instructions for installing Ubuntu on WSL 2 via two methods: the Command Line and the Microsoft Store.

Prerequisites

  • Operating System: Windows 10 (Version 1903, Build 18362 or later) or Windows 11.

  • System Requirements:

    • Ensure all the latest Windows updates are installed.

    • Verify that virtualization is enabled in your system's BIOS/UEFI settings.

  • Check Windows Version:

    • Press Win + R, type winver, and press Enter.

Step 1: Enable WSL

Option A: Using PowerShell (Recommended for Windows 11 and newer Windows 10 versions)

  1. Open PowerShell as Administrator:

    • Search for "PowerShell" in the Start Menu, right-click, and select Run as administrator.

  2. Execute the following command:

    wsl --install
    

    This command enables the necessary WSL features and installs the default Ubuntu distribution.

  3. Restart your computer when prompted to complete the installation.

Option B: Manual Installation (For older Windows 10 versions)

  1. Open PowerShell as Administrator.

  2. Enable the required features:

    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    
  3. Set WSL 2 as the default version:

    wsl --set-default-version 2
    
  4. Restart your computer to apply the changes.

Step 2: Install Ubuntu on WSL

Method 1: Using the Command Line

  1. Open PowerShell as Administrator.

  2. List available distributions:

    wsl --list --online
    

    This command displays a list of available Linux distributions.

    The following is a list of valid distributions that can be installed.
    The default distribution is denoted by '*'.
    Install using 'wsl --install -d <Distro>'.
    

    NAME FRIENDLY NAME

    • Ubuntu Ubuntu Debian Debian GNU/Linux kali-linux Kali Linux Rolling Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS Ubuntu-24.04 Ubuntu 24.04 LTS ...
  3. Install your desired Ubuntu version (e.g., Ubuntu 24.04 LTS):

    wsl --install -d Ubuntu-24.04
    
  4. You’ll see an indicator of the installation progress in the terminal:
    Installing: Ubuntu 24.04 LTS
    [==========================72,0%==========                 ]
  5. Use wsl -l -v to see all your currently installed distros and the version of WSL that they are using:

    NAME            STATE           VERSION
      Ubuntu-20.04    Stopped         2
    * Ubuntu-24.04    Stopped         2
    
  6. Upon completion, Ubuntu will launch, prompting you to create a UNIX username and password.

Method 2: Using the Microsoft Store

  1. Open the Microsoft Store from the Start Menu.

  2. Search for "Ubuntu" in the store's search bar.

  3. Select your preferred Ubuntu version (e.g., Ubuntu 24.04 LTS) and click Get to begin the installation.

  4. Once installed, click Launch or open Ubuntu from the Start Menu.

  5. On the first launch, you'll be prompted to create a UNIX username and password.

Step 3: Verify WSL Installation

  1. Open PowerShell.

  2. Check the installed distributions and their WSL versions:

    wsl --list --verbose
    

    The output should resemble:

    NAME            STATE           VERSION
    * Ubuntu-24.04  Running         2
    

Optional: Set Ubuntu as the Default WSL Distribution

If you have multiple distributions installed and wish to set Ubuntu as the default:

wsl --set-default Ubuntu-24.04

Optional: Install Ubuntu Without Microsoft Store Access

If you don't have access to the Microsoft Store or prefer manual installation:

  1. Download the Ubuntu .appx package from the official Ubuntu releases.

  2. Convert the .appx file to a .zip file and extract its contents.

  3. Run the installer to complete the installation process.

Post-Installation: Update and Upgrade Ubuntu

After installation, it's advisable to update your Ubuntu packages:

sudo apt update && sudo apt upgrade -y

You're All Set!

You now have Ubuntu running on WSL 2, providing a powerful and integrated Linux environment within Windows. Utilize it for development, scripting, and more, all without the need for a separate virtual machine.

For more detailed information and advanced configurations, refer to the official Ubuntu documentation: (Ubuntu Documentation)



Recent posts

TIKAM CHAND
Shadow DOM in JavaScript
How ToJavaScript
955
34