Digital Marketing Agency | SEO, Paid Social & PPC

How to install Linux WSL2 on Windows

Share This Post

When Microsoft announced the Windows Subsystem for Linux, a means to run true Linux inside of Windows without the need to set up a virtual machine, many people’s jaws dropped. This was a major game-changer for Microsoft. The project has received a significant amount of attention, and the most recent and advanced version is WSL2.

The Linux experience on Windows 10 and Windows 11 is improved further and made even more wonderful as a result of this update. Now that version 1.0 has been released, it is easier than it has ever been to set up WSL2 on your Windows PC. Additionally, GUI applications are now supported on Windows 10, as well.

how install wsl2 windows

How to setup WSL2 on Windows 10 and Windows 11

There is now a brand new method that is really easy to use to get WSL2 installed and operational on your computer running Windows 10 or Windows 11. You need to be running Windows 10 version 21H1, 21H2, or 22H2 to get the very latest version, or Windows 11 version 21H2 with all of the November updates applied to get the very latest version of Windows 11. After ensuring that this is in place, launch PowerShell and type in the following command:

wsl –install

That sums it up nicely. The process of setting up will start, and you may kick back and relax until it is done. WSL will automatically download and install Ubuntu, in addition to activating all of the necessary system functions, by default. You can prevent the installation of a distribution during setup by including the — no-distribution tag in the installation command if you do not want a distribution to be installed.

WSL is now available for download from the Microsoft Store, and users who opt for the streamlined installation process will automatically receive this version. You also have the option to download it directly from its listing on the Microsoft Store website.

How to setup Windows Subsystem for Linux optional component for WSL 1

How to enable the optional Windows Subsystem for Linux component for the WSL 1
WSL2 is the current standard, but if for some reason you want to utilize WSL1 in addition to it, you’ll need to enable the optional Windows Subsystem for the Linux component. This is because WSL2 is currently the standard. You have two options to choose from, which is a fortunate development. The first option is to modify the install command that was presented earlier by including the —enable-wsl1 switch.

However, you are also free to enable the component whenever you see fit, even after you have successfully brought WSL2 online and are using it. Launch PowerShell while logged in as the administrator and enter the following command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Because you will eventually have to restart your computer, setting the norestart switch ensures that you won’t be abruptly ejected from whatever it is you’re working on. If you want the computer to restart right away, just leave this part of the command off at the very end.

How to setup WSL2 for Linux distros

One of the advantages of WSL2 is that it does not compete directly with WSL1. It merely follows in its footsteps. This translates to the fact that you are able to execute Linux installations that contain a combination of different versions. Either one can be selected as the default, and you can also assign a version to each individual Linux distribution that you have installed on your computer.

First, let’s take a look at some of the most important PowerShell commands that you’ll need to be familiar with.

How to setup WSL2 as the default

You can make WSL2 the default version of Windows Subsystem for Linux if you want everything to operate on it as soon as you install it.

wsl –set-default-version 2 

Listing installed Linux distros and their WSL version

Because WSL2 is now the default, any Linux installation that comes after that will automatically utilize it. It is simple to determine which version of WSL your currently installed Linux distributions are utilizing.

wsl —list —verbose

If you use the verbose flag, you will receive an explanation of which version of WSL is associated with which Linux installation. If you don’t have it, all you will see is a list of the different versions of Linux that you have installed.

How to modify the version of WSL installed on each Linux machine

While making WSL2 your default setting will ensure that it is used for everything you install in the future. If everything is already in place, the conversion will have to be done manually. In the same vein, you are free to switch between versions 1 and 2 or run a combination of both on your computer if you so choose.

wsl —set-version distribution name=””> versionnumber>/versionnumber>/distribution> /distribution>

To illustrate this point, let’s say you have a Debian installation running on WSL that you want to migrate to WSL2. In this scenario, you would enter

wsl –set-version debian 2

Launch specific Linux installations in PowerShell

Launch specific Linux installations using PowerShell with the command wsl —set-version debian 2.

If you only have one version of Linux installed, you can use the command typing to switch between versions.

wsl

in PowerShell will open the associated bash shell in the current working directory. However, if you have more than one, you can use this command to run a particular distribution if you like.

wsl -d “distribution name=””>”/distribution> “/distribution>”

Once you’ve finished, you may start typing.

exit

will re-enter you into the PowerShell prompt.

Moving forward, you have the freedom to explore and install as much Linux as you desire. While our extensive guide can assist you throughout the process, once WSL2 is configured to your preferences, it will largely operate inconspicuously in the background.

If you are going to use WSL, it is highly recommended that you download the Windows Terminal program from the Microsoft Store. In spite of the fact that you can just use the default terminal that is included with each or start it through PowerShell as was demonstrated earlier, the Windows Terminal features a cool tabbed design that enables you to run numerous shells at the same time. Open up PowerShell, Linux, Azure Cloud Shell, and even Command Prompt all in the same window so that they can be compared to one another.

Would you like to read more about how to install wsl2 windows-related articles? If so, we invite you to take a look at our other tech topics before you leave!

Subscribe To Our Newsletter

Get updates and learn from the best