What is Windows Subsystem for Linux (WSL
Windows Subsystem for Linux (WSL) is a powerful tool that helps us install a desired Linux distribution (Ubuntu, OpenSUSE, Arch Linux, etc.), without the need for an overboard installation of a virtual machine, or dual boot machine
Pre-requisites for the Installation of WSL
You should be using Windows 10 version 2004 or higher (or Build 19041 or higher) or Windows 11 if you want to run the WSL command.
One way to check is by opening the “RUN” window, and typing “winver”, as shown below.
The window that appears shows the version of Windows that you have.
You can also check the Windows version using the command prompt.
Let’s look at the command a bit. Here, the “findstr” finds the strings that start with “OS Name” and “OS Version”
Install WSL
Next, you need to open the “Turn Windows Features On or Off”
On the window that you see above, you need to turn on “Windows Subsystem for Linux” and “Virtual Machine Platform”
After you turn on both the features mentioned above, the system will apply the changes and you will have to restart your machine. A restart can be avoided using the following commands to turn on “Windows Subsystem for Linux” and “Virtual Machine Platform”
For Windows Subsystem for Linux,
For Virtual Machine Platform,
Once the supportive Windows version is in place, now with a single command we can install WSL. Open the command prompt or Powershell with administrative privileges, and enter the following command.
wsl —install
But wait!
This will by default install Ubuntu. Specifically, you can install a Linux distribution of your choice.
Before that, we can check the available Linux distribution online. So, by entering the following command, we will be able to see the all Linux distributions that we can install in WSL.
We can install a specific Linux distribution using the following command.
wsl —install —d <Linux distro>
After the successful installation is over, the CMD looks as follows.
Sometimes you may encounter an error as follows.
Here the error message says the WSL2 requires an update to its kernal component.
To update to WSL 2, you need to be running Windows 10 or Windows 11.
And following are the individual requirements for x64-based PC and Arm64-based PC.
For x64 systems: Version 1903 or later, with Build 18362.1049 or later.
For ARM64 systems: Version 2004 or later, with Build 19041 or later
To check if it is an x64 or ARM64 system, use the following command.
You can check the version/ build using the method mentioned in the initial segment of this article.
Download the Linux Kernal Update Package
Now, you can download the Linux kernel update package. If you want to download the update package from the Microsoft Store, use one of the following commands.
You can use either wsl.exe --install or wsl.exe --update
Or, depending on whether you are using the x64-based or ARM64-based PC, you can manually download and install the update package.
For x64-based PC,
For ARM64-based PC,
Set WSL2 as default
Now, WSL2 can be set as our default version using the following command.
Finally, we have the terminal window
Use the Ubuntu terminal as a new tab of the Windows terminal
You can also have the Linux terminal as a new tab of the Windows Terminal. For this, when you open the Windows terminal, you may notice the downward arrow. Click it and choose the terminal window of your choice. Here, it is the Ubuntu terminal.
Comentarios