Skip to main content

Command Palette

Search for a command to run...

Ditching Linux for WSL 2

Windows + Linux = 🀯🀯🀯

Updated
β€’2 min readβ€’View as Markdown
Ditching Linux for WSL 2
D

I'm a web developer and a college sophomore, currently focused on JAMStack and building scalable applications.

WSL 2 == Microsoft's love for Linux

Development on Linux

I switched to Linux last year and shifted my development completely to the Linux ecosystem. Tried out arch, Manjaro, Pop OS!, Ubuntu, MX Linux. Development is really productive with a Linux environment.

Gaming on Windows

A few months back I upgraded my potato to a gaming laptop which of course came with Windows pre-installed, I also started gaming. I ended up doing dual boot to run Ubuntu as my daily driver for development, but this eventually meant a redundant set of tools on Windows as well.

Windows πŸ’– Linux

Windows released the Windows Subsystem for Linux 2 in May 2019. WSL 1 was a compatibility layer for running Linux binary executables on Windows. WSL2 built on top is built on the core technology of Hyper-V to provide better support and improved performance running a Linux kernel.

Why WSL 2 instead of native Windows

Most production environments run on Linux and with WSL 2 environment the tooling available on development become the same as in production. Also WSL 2 is super easy to set up and get started with.

Set up WSL 2 on Windows

Open an elevated Powershell (Run as administrator) from the start menu and use the following commands to get WSL 2 up and running.

image.png (Note that: WSL 2 is only available in Windows 10, Version 1903, Build 18362 or higher)

Step 1 - Enable the Windows Subsystem for Linux

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 2 - Enable the Virtual Machine feature

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

image.png You need to restart your PC after this step.

Step 3 - Download & install the Linux kernel update package

https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi

image.png

Step 4 - As a final step set WSL 2 as your default version

wsl --set-default-version 2

image.png

Now you can install your favourite Linux distro from the Microsoft Store. After the installation completes you'll need to restart and complete the setup of your Distro.

Enter the username and password for root user and you are good to go.

ubuntuinstall.png

Set your default Linux distro for WSL 2.

wsl --set-version <distribution name> <versionNumber>

image.png

πŸŽ‰πŸŽ‰πŸŽ‰That's it you have successfully set up WSL 2 and can now begin your journey to become a 10x Developer.

Feel free to reach out to me on Twitter @cryptus_neoxys and connect with me on LinkedIn.


Refs & Resources

Microsoft Docs

Ubuntu Wiki

ITProTV -YouTube

If you loved the article and would like to support me, you can buy me a coffee.

R

How does it works beyond the last point? I mean, I need a separate shell to access Linux tooling or can I call them directly from the Windows terminal?

I currently use Linux at work and Windows at home. I was toying with the idea to switch to Linux one more time (if Windows 11 fails to impress me, at least) because my workflow works better with its tools, but I'm 100% sure I'll miss playing my games at some point and I have absolutely no time/patience/desire to dive deep into gaming on Linux for now (even though I'm trying to learn better how to game on Linux, I won't be installing Linux on my computer anytime soon just for that).

I've ignored WSL for far too long, but ever since WSL2 launched, I'm only seeing people talking good things about it. This seems like the best of both worlds for me.

1
D

yep, you have to access all of the Linux tooling (and even GUI apps now) via the WSL shell.

If you do decide to make the switch, from my experience (mostly JS, some toying with GOLang) I can definitely say WSL2 won't disappoint.

S

Makes me wanna switch

D

Worth a try xD

A

Nice tutorial.

1
D

Thank you Aniket, glad you liked it.