Recently, you might have also heard about the news that Microsoft loves Linux. Since last few years, Microsoft has been doing a lot to bring the Linux world closer to the Windows world. WSL is also part of that initiative.
What is WSL?
WSL stands for
Windows Subsystem for Linux. It is an optional feature which is available on
Windows 10 and
Windows Server 2019.
Windows Subsystem for Linux (aka WSL) allows you to run the Linux terminal environment, other command line tools, utilities and applications directly on Windows platform, unmodified.
You do not really have to recompile your binaries for enabling them to run on windows. You also do not need to worry about overhead of booting a virtual machine or dual boot up, because they are not required at all.
How does it work ?
The first version of WSL is commonly called as
WSL 1 while the current latest version is called as
WSL 2. On the architectural level, there are some basic differences between these two versions. I will not go into details of those differences. I would try to cover basic idea behind the WSL so that we can understand how does it work.
As we said earlier, enabling WSL does not need you to setup any virtual machine or setup of dual boot-up is also not required. Windows comes with very tiny virtual machine (they call it
lightweight utility VM).
When you enable WSL feature, the
lightweight utility VM is installed. Please note that although technically it is very tiny virtual machine, it is very small and very efficient. It takes around
~1 second to boot and it also consumes very less amount of compute resources as compared to the virtual machine.
What can you use it for ?
You can run common command-line tools such as
awk, or other ELF-64 binaries. You can use various tools like vim / emacs.
You can also install additional software using GNU/Linux package manager.
If you want to use it for development purposes, then you can install services like MySQL, MongoDB or any other services of your choice.
I hope this gives you basic idea about what you can use WSL for.
How to enable WSL ?
Below steps are for enabling
WSL 2 on the
Windows 10 machine.
The windows 10 version should be higher than
You can check current version of windows by running
ver command on command prompt. If it is lesser than
Build 19041, then install the updated version 2004, Build 19041 or higher.
As this is optional windows feature, you can turn it on or off from Turn Windows features on or off. Once you are on Turn Windows features on or off panel, you need to enable two features:
- Virtual Machine Platform (for WSL2)
- Windows Subsystem for Linux
Once these two are selected click on OK.
PowerShell as Administrator and run below two commands. First command enables Virtual machine platform, second one enables WSL and third one sets WSL version to 2.
|# STEP 1: Enable Virtual Machine Platform feature|
|dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart|
|# STEP 2: Enable WSL feature|
|dism.exe /online /enable-feature /featurename:Microsoft–Windows–Subsystem–Linux /all /norestart|
|# STEP 3: Restart Win 10 Machine|
|# STEP 4: To set the WSL default version to 2.|
|# Any distribution installed after this, would run on WSL 2|
|wsl —set-default–version 2|
Once this is done, restart your windows machine to complete the installation.
Unexpected error: 0x1bc
When you try to run
WSL Set Default Version command to set default version to 2, you may get an error as shown in the below snapshot.
After searching a bit about it, I found a GitHub issue. So, if you get the same error, then you may want to follow below steps in order to resolve it:
- Download the latest WSL2 Linux Kernel (wsl_update_x64.exe)
- Run the exe with elevated permissions (i.e. Run as Admin)
- If Hyper-V is enabled, then try to disable it from the windows features.
I just had to download and install the update to
WSL 2 Linux Kernel and the command worked for me.
Install Linux Distribution
Select any one entry from search results. The new panel will show details of the selected distribution. Then click on Get button to install it. I am selecting Ubuntu because I have been using it since very long and I like it. You can select any of the distribution.
Please note that NOT all of them are free. Some of the distributions have charges and if you want those distributions, you will have to buy them from store.
I would suggest you to use free versions unless you have any specific requirement which is not fulfilled by it.
If you wish, you can also install multiple distributions to play around.
Once a Linux distribution is installed and you try to open the Linux distribution, first thing you will be asked is to create a
password. This account is treated as Linux administrator and has all rights to run the
This username and password is very specific to the distribution and they have nothing to do with your windows credentials.
Once user is created, it would be default user and you would be signed in automatically using this admin user credentials.
As these credentials are specific to distribution, everytime you
add a new distribution, you will have to setup an admin account for that distribution. Even if you
reset a distribution, system will ask you to create admin user.
Once the Linux distribution GET operation is done, Microsoft store would show a Launch option as shown below. As soon as you click on Launch, it will start a command prompt to extract / install downloaded files. It will also ask you to set your username and password.
When you run a newly added Linux distribution, you will be asked to wait for some time, this time may range from a minute to couple of minutes. This time is used for decompress all the files from Linux distribution and store them somewhere on your PC.
All the subsequent launches should be complete within a second.
Now the setup is complete.
Run and Verify
Next thing is to run and verify that our setup works.
When you install the distribution and launch it, it automatically starts the Linux terminal after extract/install is done. But I am sure you would also want to know how to run the WSL Linux Distribution.
Run PowerShell as Administrator and run the command
wsl --list to get the list of installed distributions. If you have followed all above steps, it should show at least one distribution.
If you have only one distribution installed, you can start Linux terminal by just typing
If you have more than one distributions installed, then you will have to specify the name of distribution as shown in below code snippet.
|## List all distributions installed|
|## Use -d parameter to run a specific distribution from the list|
|## If you have only one distribution installed,|
|## Then only WSL and enter would start the installed distribution|
|wsl –d <<distribution–name>>|
The commands from above snippet runs on both PowerShell as well as on Windows command prompt.
Playing Around It !
- If you try to run
notepad.exefrom the Linux terminal, it will open notepad from Windows 10. Any command that Linux does not understand is handed over to Windows kernel.
- You can install any packages using Linux package manager.
- You can see the Linux file system as well. Go to Run (Win + R) and then type
\\WSL$and hit enter. It should show some distributions which are running. You can open the respective folders to view the Linux files.
- You can use vim to create file at any path on Windows machine.
Also, if you want really see how much time is taken by lightweight utility VM to start the Linux distribution then try below steps:
wsl --shutdown, this will shutdown the lightweight utility VM. All running instances of wsl distributions would be shown as stopped if you run
wsl --list --verbosecommand.
wsl -d <<name>>, to start the WSL Linux distribution which is already installed on the machine.
You would see how amazingly fast it is. The Linux terminal would be shown instantaneously.
I hope you enjoyed this article. Let me know your thoughts.