What is WSL 2?
Today I’m going to help you setup a Windows supported version of Linux on your Windows installation. It’s as easy as opening a command prompt, or Powershell if you’re so inclined, and following a predictably more involved installation process. The feature is called the Windows Subsystem for Linux (Version 2), although most people just call it WSL 2.
Originally announced in May 2019, it wasn’t until March of the following year when I began creating Ruby on Rails tutorials on the Deanin YouTube channel, after a yearlong hiatus, that a viewer from the comments informed me of the existence of version two. I had been stuck on version one, and its speed left something to be desired. In fairness, however, my choice of locations for my working directory were also to blame.
The location I had chosen, a folder inside of my D: directory, lead to Windows and Ubuntu sharing these files. This caused Ruby on Rails to run an order of magnitude slower than I was accustomed to from my time spent creating Rails applications on my dual-booted Linux distribution. Often times this would lead to me having enough time to do some chores while waiting for a simple “Rails new” command to finish. Before we move on to the steps, I would like to point out that this entire tutorial, as well as many others, already exists in video form over on Deanin, my YouTube channel.
You Have Been Keeping up With Your Updates, Right?
As of the time of this article, the update which contains WSL 2 is still only available via the Windows update fast track. This means that the first step for this process is going to involve visiting your Windows Update panel, clicking on the Windows Insider Program–cleverly named to provide the WIP acronym–and clicking “Get started,” which will prompt for your choice of update tracks. Ensure that “fast” is selected, and start booting up a game to pass the time.
You’re now going to be subjected to multiple restarts and Windows updates until you finally either reach a version at or above 18917 , or run out of updates. Should you run out of updates, you’ll have to tell Windows to check for new updates.
If you’re unsure of which version of Windows you’re running, you can check by opening up a command prompt and typing “ver”.
My version as of the time of this article is 19592. You’re probably looking for anything around that number or later, and you’ll be fine.
It's Finally Time to add WSL 2!
There’s a few commands that you’ll have to run now. The first will enable the actual Windows Subsystem for Linux, and the second will enable the Windows Virtual Machine Platform. It’s important to note that you may still need to set the WSL version to 2 after completing these steps, which we’ll cover how to do after the code block.
And then enable the Window's Virtual Machine Platform:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
After you run both of those commands, you’ll once again want to restart your computer. If you now open your PowerShell and run it as an administrator, you can use the command:
wsl -l -v
To see which Linux Subsystems you have installed, and the versions they run on. If you don’t see the version you’re looking for, you can head over to the Microsoft Store (Application on your computer, not the website, although I guess that might work too?) and search for it. In my case, I installed Ubuntu 18.04 after a quick search:
After installing your preferred Linux distribution, you can then return to your PowerShell to check the version with that wsl -l -v command again.
Upgrading Your WSL from Version 1 to 2!
This is the home stretch for those of you installing from scratch. For anyone just here to update to the latest version, here’s the final commands:
You can also just set WSL 2 as your default version:
wsl --set-version Ubuntu-18.04 2
And one final check to see if that worked:
wsl --set-default-version 2
wsl -l -v
And that concludes the WSL 2 setup portion of this tutorial. You could now go on to use the Ubuntu shell or PowerShell to do your Linux stuff. But I have one last program that I feel I should mention!
The Windows Terminal
Recently, Microsoft launched a new Windows Terminal that I’ve personally been using while developing on Windows. It’s not quite at the levels of ConEmu yet, but personally I prefer it as I can just pop it in while I’m in the Windows store. The configuration options are quite powerful as well, so if you’re comfortable with throwing in a few blocks of code to change your shortcuts, this might be for you!
I’ve actually been using this on several of the tutorials over on youtube.com/deanin, and it’s been wonderful, especially when running multiple server apps on different ports. I’ll just open a tab for each directory, and I’m good to go!
That's All She Wrote!
That should be everything you need to get set up! Again, all of this was covered in the video version of this tutorial. That’s the point of this blog though! I’ll try to gradually create a text version of each video over time, to hopefully help to both:
- Reach a new audience through search engine traffic
- And also give those of you who just prefer a text version of tutorials something to work with
Hopefully you found some value in this blog post, and weren’t bored to tears during your Windows Updates! I’ve been (and will continue to be) Dean, and I’ll see you in the next one, hopefully!
Disclaimer: I may be provided an Amazon Affiliate commission for any sales made through any Amazon links on this website. You pay the same as you normally would, but a small portion of what Amazon is paid goes to me.