There are a lot of advantages of having a Linux system ready to use, whenever you need to. Personally, I rely heavily on WSL in my day-to-day life. Whenever I need to run something Linux-specific, it's as easy as opening a new terminal session. I also use docker for virtualizing some services, such as databases, which can use WSL to function faster.
Prerequisites
- Windows 11 OR Windows 10 build 10.0.1903 or later
Enabling Windows virtualization and WSL features
As of today, WSL 1 and 2 require Windows virtualization features. It's also a good idea to have these features enabled by default (VMs or docker can use them). We can do that by going into Powershell (admin mode) and running the following commands:
PS C:\WINDOWS\system32> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Deployment Image Servicing and Management tool
Version: 10.0.22621.1
Image Version: 10.0.22621.1105
Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.
PS C:\WINDOWS\system32> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Deployment Image Servicing and Management tool
Version: 10.0.22621.1
Image Version: 10.0.22621.1105
Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.
Now, restart your PC and come back here. I'll wait for you :D.
Installing WSL
Already, back? Good! You've now enabled the required functionality for WSL. Now, go into the console and run (after the command finishes, Windows will probably require another restart):
wsl --install
If installation begins, continue by reading the next paragraph. If not, and the command is not found, or not available, you probably need to download and install WSL2 Linux kernel update package for x64 machines from official Microsoft's official documentation or by clicking here (I wouldn't trust a random blog post either, but the download link is hard to see in the docs, and link href is official Microsoft domain :D). After you're done installing it, you should try running the previous command. At this point, everything should work fine.
The only thing we need to do now, is run the following command and we're done.
wsl --set-default-version 2
Right now, you either already have the latest Ubuntu WSL installed (behaviour on newer versions of wsl), or have to install it from Microsoft Store, just search Ubuntu and click on download. It was pretty easy, wasn't it?
I hope you enjoyed this article/blog post!
If you have any questions, problems or want to start a discussion, don't hesitate and write me an email!