Install Ubuntu on WSL 2
WSL2 (Windows Subsystem for Linux 2) is a compatibility layer allowing users to run a full Linux kernel and native Linux applications on Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.
Install WSL command
Run PowerShell or Command Prompt as administrator
Run the “wsl —install” command to install. This will install default version of WSL.
>wsl --install
Restart PC
Check wsl Installation
>wsl --version WSL version: 2.2.4.0 ....
Check installed Ubuntu with command “wsl --list --verbose” (or wsl -l -v).
>wsl -l -v NAME STATE VERSION Ubuntu Stopped 2
Enter Ubuntu Distribution.
>wsl -d Ubuntu root@DESKTOP-FMBB4IH:/mnt/c/WINDOWS/system32#
Check the installed Ubuntu version.
root@DESKTOP-FMBB4IH:/mnt/c/WINDOWS/system32#lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy
Change the installed default Linux distribution
To check the version of default Linux distribution
Check the above “Install WSL command” procedure numbers 5, 6, and 7.
Check available distribution name using command wsl --list --online(wsl -l -o).
>wsl -l -o Install using 'wsl.exe --install <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 OracleLinux_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1 openSUSE-Leap-15.6 openSUSE Leap 15.6 SUSE-Linux-Enterprise-15-SP5 SUSE Linux Enterprise 15 SP5 SUSE-Linux-Enterprise-15-SP6 SUSE Linux Enterprise 15 SP6 openSUSE-Tumbleweed openSUSE Tumbleweed
To change the installed default Linux distribution to Ubuntu-22.04.
Syntax: wsl --install -d <Distribution Name>
>wsl --install -d Ubuntu-24.04 Installing: Ubuntu 24.04 LTS Ubuntu 24.04 LTS has been installed. Launching Ubuntu 24.04 LTS... Installing, this may take a few minutes... Please create a default UNIX user account. The username does not need to match your Windows username. For more information visit: https://aka.ms/wslusers Enter new UNIX username:
Enter username and password 2 times when prompted.
Changed distribution is ready to use.
Check the above “Install WSL command” procedure numbers 5, 6, and 7.
To enter the distribution
Just after installation or changing the distribution, the distribution is opened. To open the distribution from next time, enter the following command:
Syntax: wsl -d <Distribution Name>
>wsl -d Ubuntu-24.04
To exit the distribution
>exit
To uninstall the distribution
Syntax: wsl —unregister <Distribution Name>
>wsl --unregister Ubuntu-24.04
Reference
Subscribe to my newsletter
Read articles from PRABHAT SHRESTHA directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by