How to install Ubuntu using Windows Subsystem for Linux (WSL2)

Using Windows Subsystem for Linux (WSL), users can install any Linux distribution directly on their Windows machine without having to install a virtual machine or through dual booting. And if you have Windows 11, then you can also run Graphical applications directly on Windows.

In this tutorial, we will look at the complete procedure of Installing Ubuntu on Windows WSL2, note that I’m using Windows 11 in this tutorial, but you can also follow along if you have Windows 10.

Install WSL2

From the start Menu, search for ‘PowerShell’ application and launch the application using Administrator privileges.

Run Powershell As Administrator From The Start Menu
Run PowerShell As Administrator From The Start Menu

In Windows PowerShell, type the following command and press Enter :

wsl --install

Wait for the WSL kernel and GUI app support (on Windows 11) to be installed, and then finally reboot your PC for changes to take effect.

Installing Ubuntu On Windows Using WSL2
Installing Ubuntu On Windows Using WSL2

Close the PowerShell window after the command stops running, and then reboot your system for the changes to take effect.

Make WSL2 the Default version

Now, open PowerShell again with Admin privileges and run the following command :

wsl --set-default-version 2

Install Ubuntu

If you want any other version of Ubuntu, then you can list all available distributions and specify the version which you want to install using this command:

wsl --list --online
wsl --install -d Ubuntu-VERSION
List Available Distributions On WSL2 1
List all available Distributions On WSL2

To Install the latest Ubuntu, run:

Installing the latest version of Ubuntu
Installing the latest version of Ubuntu

Post Installation configurations

Once installed, A second Ubuntu Terminal will open (If it does not, simply search and launch it from your Start menu), and you will be asked to create a User account and Password on Ubuntu :

Create A New Username And Password For Your User
Create A New Username And Password For Your User

After installation, It is recommended that you fully update your Ubuntu by typing the following command:

sudo apt update && sudo apt full-upgrade
Updating Ubuntu on WSL2
Updating Ubuntu on WSL2

Install Applications

Now that you have Installed Ubuntu on your machine, you can begin installing applications using the sudo apt install appname command, for example, here, I have installed the Ranger file manager :

sudo apt install ranger
Install Ranger
Install Ranger

Summary

WSL is definitely a boon for developers who are interested in developing cross-platform applications, as they do not have to use a Virtual Machine or dual boot their system every time they have to test a new feature that they added to their application. Now with the support for GUI applications, even a moderately techie person can now access the huge library of Linux-only command line applications.

References

Official WSL Documentation