Aditya Kanekar
Posted on November 15, 2020
Background
Most of the open source software's are developed for Linux distros and this makes it difficult to run on Windows. Of course you can run a Ubuntu VM on Hyper-V or Virtual Box and install your development environment on the machine as you would on a regular machine.
However to run the VM's on your machine your machine should have enough juice to run the VM's smoothly and its not seamless either if you want to transfer files between your Windows host and your VM. You can also setup dual boot with Windows 10 and Linux, however maintaining different operating systems on a machine is a pain.
With WSL, installing Linux distros in Windows 10 is as easy as installing a app. You can share files easily between Windows and your Linux distro and you can also develop for Linux right inside Windows 10.
But I already have WSL1, can I upgrade?
Sure you can upgrade from WSL1 to WSL2, you can refer my post to upgrade from WSL1 to WSL2.
Windows Subsystem for Linux (WSL)
Most of you might have heard of Windows Sub-system for Linux AKA WSL. What it enables you to do is install Linux distros on your Windows 10 machine like a app from Windows 10. Yes, you heard it right install distros as app. However things are not that simpler if you have Windows 10 Home Edition since WSL uses Hyper-V to run a VM behind the scenes. The other problem is Docker or MicroK8S are not supported on WSL and this was a bit of a downer. However it was a step in the right direction from Microsoft.
WSL 2
Microsoft has resolved most of the issues which were bugging WSL with WSL 2. WSL 2 does uses VM behind the scenes but its managed, also it uses full Linux Kernel built by Microsoft unlike WSL. You can learn more about WSL here,
https://docs.microsoft.com/en-us/windows/wsl/compare-versions
Pre-Requisites
Installing / Upgrading WSL 2
You can refer the instructions for installing WSL 2 on the official Microsoft site.
https://docs.microsoft.com/en-us/windows/wsl/install-win10
VS Code
I will be using VS Code for this article and its my choice of IDE for development (I am obsessed with VS Code :p)
https://code.visualstudio.com/download
Install following plugins,
- Remote WSL
Windows Terminal Preview - Optional
You can install Windows Terminal from here. This step is not necessary, however I will recommend you to try it.
Install Linux Distro from Windows store
For this article I have install Ubuntu 20.04LTS from Windows Store. Assuming you have completed above steps for installing WSL 2 on your machine. This step should be straightforward. Jut got to your Windows Store and search for Ubuntu. Install Ubuntu 20.04LTS.
Once you install, search for Ubuntu in your Windows Search bar and click it.
Since the app is being launched for the first time, just follow the installation steps. After installation you will be asked to create username and password, give username and password of your choice and you are all set.
Launching Ubuntu
Assuming you have completed all the steps, just search for Ubuntu or if you have installed Windows Terminal, select the shell you want to open as shown below,
Listing installed distros
Run following command in Powershell or command prompt to display all installed distros,
wsl -l -v
You should be able to see similar output as shown below,
NAME STATE VERSION
* docker-desktop Running 2
Ubuntu-20.04 Stopped 2
docker-desktop-data Stopped 2
In the next part we will create a sample dotnet core console app and debug it in Windows 10 while developing on Ubuntu-20.04.
Till then, Happy Coding !
Posted on November 15, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.