There was a time when Windows was completely separate and different from Linux. Windows used to think of Linux as their competitor. But the time has changed, and Windows realized that no user could get the actual feeling and knowledge of computing without learning Linux. Finally, in 2016 Windows came up with an arrangement where traditional Windows users can use the command-line interface of the Linux shell. That conjugated system is known as the Windows Subsystem for Linux (WSL).
You can install the windows subsystem for Linux alongside your Windows system to use the command-line based Linux tools, software, and other tasks that were not possible to run on Windows.
WSL1 vs. WSL2: Which One is Better for You?
The windows subsystem for Linux (WSL) has two active versions. They are named WSL1 and WSL2. The WSL1 works better in older hardware configurations, and it gives a more smooth performance. On the other hand, the Linux kernel-based WSL2 supports Microsoft’s Hyper-V feature.
The WSL1 and the WSL2 both have a functional framework that is compatible and enough to install the Linux kernel. If you have more than one virtual machine install on your system, in that case, you need to select the WSL2 to get the full support of the Linux kernel.
If we look at the hardware configuration system, WSL1 and WSL2 can provide stable performance on low memory and cache support. Ultimately, the WSL2 supports the full Linux kernel compatibility, but the overall performance of WSL1 is better than the WSL2. The choice is yours; you have to choose between the WSL1 and WSL2 while you want to install the windows subsystem for Linux.
Prerequisites of Installing the WSL
Before you start the process of windows subsystem for Linux, make sure that your Windows system is upgraded at least to the build version 1607. It is recommended to update and upgrade the system up to the build version 2004. You can see in the picture below that my system is already upgraded up to 20H2, which is the latest build version of Windows.
The hardware architecture of your PC needs to be in the 64-bit version. You can’t install the WSL on a 32-bit machine. Most importantly, you also need to have the administrative power of your system.
Install the Windows Subsystem for Linux
We have now learned the differences between the WSL1 and WSL2 and the prerequisites of installing the windows subsystem for Linux. The installation process of the WSL is straightforward and easy. In this post, we will see installing the Windows subsystem for Linux on a Windows system.
Step 1: Enable the WSL for your system
There are two methods of enabling the windows subsystem for Linux. The first method allows you to enable the WSL from the command prompt. And, the second method is mostly based on the graphical user interface settings. Here, we will cover both CMD and GUI-based methods of enabling the WSL on a Windows system.
Method 1: Enable Windows Subsystem for Linux by CMD
Here, you have to run your command prompt as an administrator. You can find the cmd tool on the search bar of your Windows menu. Then click on the run as administrator button. That will provide you the root privileges and work under the system32 directory.
Now, run the following command-lines given below on your command prompt to enable the WSL feature. This command will allow you to enable the WSL without restarting the system. The following command will active the Deployment Image Servicing and Management (DISM) on your Windows machine.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Method 2: Enable Windows Subsystem for Linux by GUI
In this method, you need to enter the Control Panel of your system, then find the Programs and Features section. From the Program and features section, select the Turn Windows Features On or Off. It will open a new dialogue box. From the dialog box, find the Windows subsystem for Linux and enable it. After you click on the Done button, it will ask you to restart your system.
Step 2: Install the Linux Kernel
To install the Linux kernel on your Windows machine, open the Microsoft Store and search for your desired distribution of Linux. Usually, Ubuntu, Kali Linux, SuSE Linux, and a few Linux distributions are available on the Microsoft store.
To install the Linux kernel, just click on the Get button. The approximate size of the Ubuntu kernel for windows subsystem for Linux almost 450MB. It may take a while to be installed. Here, I am going to install Ubuntu Linux.
Step 3: Get Started With The Windows Subsystem for Linux
Once the installation of the Windows subsystem for Linux is done, you will get a notification on your system tray. You can directly click on the Open button from the Microsoft Store, or you can find the Ubuntu Linux from the Start menu of your Windows system. Once you click on Ubuntu, it will take you to the command prompt to finalize the installation process.
In this step, you will be asked to set a username and a password to configure the Windows subsystem for Linux. Once you are done with your account’s configuration, it will show you your current version of your Linux distribution, IP configuration status, and other support links. You can now run the sudo
commands on the command prompt.
Before you run the WSL commands, you may need to install the WSL tool on your system. Run the following command to get the WSL tool on your Windows Subsystem for Linux.
sudo apt install wsl
You can also perform the following command-lines given below to check the release information and the details of the WSL.
lsb_release -a wsl -help wsl -l wsl
You can also assign a dedicated user to your Windows Subsystem for Linux arrangement by running the following command.
wsl -d Ubuntu-20.04 -u ubuntupit
Final words
Installing the windows subsystem for Linux provides you the hardware virtualization to install the Linux kernel on your Windows system. It works on the sandbox method; thus, it doesn’t affect your original operating system and doesn’t slow down your computer. If you are a newcomer to Linux, the Windows subsystem for Linux could be a strong start.
In the entire post, I have described the requirements and the procedure of installing the windows subsystem for Linux on your machine. If you find this post useful and informative, share it with your friends and the Linux community. If you are more interested in the WSL, you can visit the webpage of Ubuntu WSL.
“but the overall performance of WSL1 is better than the WSL2. ” On which grounds you got that conclusion?
WSL2 performance is by far better than WSL1. In tests conducted for my company, on same hardware, in the same operating system (Ubuntu 20.04) WSL2 performs ~30% faster. WSL2 performs almost as good as native Linux (same hardware).