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
, typewinver
, and press Enter.
-
Step 1: Enable WSL
Option A: Using PowerShell (Recommended for Windows 11 and newer Windows 10 versions)
-
Open PowerShell as Administrator:
-
Search for "PowerShell" in the Start Menu, right-click, and select Run as administrator.
-
-
Execute the following command:
wsl --install
This command enables the necessary WSL features and installs the default Ubuntu distribution.
-
Restart your computer when prompted to complete the installation.
Option B: Manual Installation (For older Windows 10 versions)
-
Open PowerShell as Administrator.
-
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
-
Set WSL 2 as the default version:
wsl --set-default-version 2
-
Restart your computer to apply the changes.
Step 2: Install Ubuntu on WSL
Method 1: Using the Command Line
-
Open PowerShell as Administrator.
-
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 ...
-
Install your desired Ubuntu version (e.g., Ubuntu 24.04 LTS):
wsl --install -d Ubuntu-24.04
- You’ll see an indicator of the installation progress in the terminal:
Installing: Ubuntu 24.04 LTS [==========================72,0%========== ]
-
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
-
Upon completion, Ubuntu will launch, prompting you to create a UNIX username and password.
Method 2: Using the Microsoft Store
-
Open the Microsoft Store from the Start Menu.
-
Search for "Ubuntu" in the store's search bar.
-
Select your preferred Ubuntu version (e.g., Ubuntu 24.04 LTS) and click Get to begin the installation.
-
Once installed, click Launch or open Ubuntu from the Start Menu.
-
On the first launch, you'll be prompted to create a UNIX username and password.
Step 3: Verify WSL Installation
-
Open PowerShell.
-
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:
-
Download the Ubuntu
.appx
package from the official Ubuntu releases. -
Convert the
.appx
file to a.zip
file and extract its contents. -
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)