If you’re one of those Devs/ITPros using the Windows Subsystem for Linux (WSL) you know how useful and powerful it can be. We announced during Microsoft Build last week that WSL2 will be broadly available in June. But I could not wait. Here’s how I installed it. It’s pretty simple.
Check it out!
First, Windows Subsystem for Linux requires Hyper-V and virtualization enabled on your computer.
Second, if you wait until June, you will get the update that is required for WSL2 to run properly on a Windows Server 2022, through the regular update process. If you cannot wait you need to install the May 24, 2022—KB5014021 (OS Build 20348.740) Preview. In the notes for the update, it does mention that you must install KB5005039, dated August 10, 2021, before installing the latest cumulative update (LCU).
In my case, my Windows Server 2022 box was already up-to-date so I was able to install the KB5014021 update by selecting it in the Optional quality update Section of the Windows Update section in Settings.
The Windows Server Installation Guide as of the writing of this post has yet to be updated to show the procedure to install WSL2 on a Windows Server 2022. However, the Install Linux on Windows with WSL documentation works beautifully as long as you’ve enabled the "Windows Subsystem for Linux" optional feature and rebooted first.
Now, to install the Windows Linux Subsystem, open PowerShell as Administrator and run this command:
Note: If you want to install additional distributions from inside a Linux/Bash command line (rather than from PowerShell or Command Prompt), you must use .exe in the command: wsl.exe --install -d <Distribution Name> or to list available distributions: wsl.exe -l -o
And reboot your system.
After the reboot the installation will resume automatically.
Set up your Linux user info
Once the Install is complete Ubuntu (the defaults distro, unless you specify one as mentioned in the Note above) will start and ask you to complete the setup by providing a username and a password for the account for your newly installed Linux distribution. See the Best practices for setting up a WSL development environment guide to learn more.
That’s it. It’s ready for you and available in your start menu.