Step-by-step guide: Installing and enabling WSL 2 on Windows 10
The WSL is a particularly useful feature in the field of information technology. It allows developers and technology enthusiasts to interact with a real Linux system. While this feature is not useful on its own, it does allow for the use of various tools like Docker on Windows.
We have already explained how to install WSL on Windows 10 in a previous article. However, here we will talk about the more modern way only available with the new versions of Windows.
In this article, we will go through the different commands to execute in order to install WSL version 2 on Windows 10.
Check the version of Windows
As we have already mentioned, the following explanations will only be applicable if certain prerequisites are validated.
First, you will have to check the version of Windows. To do this, just type
winver in the Windows search bar. A new window should open.
You will need to check the following two items:
- A version number equal to 2004 or higher
- A build version equal to 19041 or higher
If these two conditions are met, everything is fine. On the other hand, if this is not the case, you will have to use the old method.
Enable WSL functionality
Instead of manually activating this feature, this time you only need to run a simple command.
First, open a command terminal as an administrator. To do this, search for
cmdin the Windows search bar, then right click and click
Run as administrator.
Once done, enter the following command in the terminal:
Once the process is completed and the installation is finished, you will only need to restart your computer.
This step will also install the Ubuntu distribution. It is possible that you want to use another distribution and this is what we will see now.
In order to use the new version of WSL (version 2) by default, we will run a new command as administrator to change the default version of WSL.
wsl --set-default-version 2
This way, the next distributions you install will use version 2.
If you want to change the version of the installed distributions individually, just run the following command:
wsl --set-version <distro name> 2
Installing a new distribution
Depending on your needs, you will probably want to install other Linux distributions like Kali, Debian, and many others.
List the distributions
In order to see which distributions can be installed, you can type the following command as an administrator:
wsl --list --online
Or more quickly:
wsl -l -o
This command should return the following result.
Install the desired distribution
Now that we know the names of the different distributions, you just have to run the following command as administrator in the command terminal.
wsl --install -d <distro name>
<distro name>parameter must match the name entered in the
We have often discussed the security aspect in the different articles. This is why it is important to keep your software up to date in order to correct potential flaws and other bugs.
To do this, it is very simple, in a terminal as administrator, run the following command:
This command will search and install the latest version of the WSL kernel.
Best practices with WSL
Now that you have the feature enabled, it is up to date and you have installed the distribution of your choice, you will probably use it.
There are several best practices recommended by Microsoft.
Among these good practices, we can mention:
- Keep the different packages installed on the distributions up to date
- Configure the file explorer to take the file architecture of your distribution
- Configure your code editor to code directly in your distribution
- Install a version manager like git
All the good ones are listed in the official documentation from Microsoft.
In conclusion, installing and enabling WSL 2 on Windows 10 is a relatively simple process that can open up a world of possibilities for developers and users alike. With its improved performance and compatibility, it can make it easier to run Linux-based applications on your Windows 10 machine, giving you access to a vast array of tools and software.
Whether you're a developer looking to test your code on a different platform or a user seeking to expand your computing capabilities, WSL 2 is a valuable addition to your toolkit. By following the step-by-step guide outlined in this post, you can get up and running with WSL 2 on your Windows 10 machine in no time. So why not give it a try and see how it can help you take your computing experience to the next level?