I use windows for most of my daily tasks, and almost all the software I prefer for my daily tasks, are windows based. Almost 90% of my time is spent on Windows, but still, the gap is there which can only be filled by Linux. Being a developer, I needed Linux for most of my tasks, one of them is deployment. Unlike Windows, Linux is free and most of the Linux versions are open-source.
As the need for Linux came, I completely made a shift to ubuntu. After shifting, I realize that there are plenty of reasons I should shift back to windows. Well, my favorite software which I used in my free time was missing there especially Adobe illustrator(I seriously love this software and this lets you explore your creativity). I came back to windows and opted for the virtual machine.
Think of a Virtual machine as a machine inside your real machine. It’s basically a concept, where most of the resources are split and are made available as a new virtual machine, though this new machine is totally virtual and acts as a real machine. This new virtual machine can be used to install another OS inside your main machine. I hope that now you have a concept of the virtual machine but as a reference, you can also read this definition by Wikipedia.
In computing, a virtual machine is the virtualization/emulation of a computer system. Virtual machines are based on computer architectures and provide functionality of a physical computer. Their implementations may involve specialized hardware, software, or a combination.
Virtual Machine is better when it comes to dual boot. As every tool has some flaws too. Virtual machine too has some cons. As I alluded, a virtual machine runs on your real machine. So each and every hardware resource which our virtual machine will need have to request from the main machine. It means that our main machine will access hardware indirectly, thus its performance will be impacted. So, what is the alternative which can be the best fit for our needs? It’s Windows Subsystem for Linux (WSL).
What is Windows Subsystem for Linux(WSL)
The WSL is a type of resource within windows OS that allows users to run a Linux command-line interface(CLI) in windows. In WSL, you can do almost all the tasks which you can perform on Linux Terminal.
WSL is based on a Virtual machine. When we download a preferred Linux distro, we are not creating a VM instance. Instead, WSL provides a layer for translating Linux system calls to Windows system calls. Thus Linux binaries are able to run in windows unmodified. We can also have the Linux process communicate with Windows Process. WSL also maps Windows services, like the filesystem and networking, as devices that Linux can access.
Why WSL is better than Virtual Machine
Instead of using a VM instance, WSL virtualizes a Linux kernel interface on top of the Windows kernel. it means that running WSL only requires a small amount of memory. And when it’s not in use, the WSL driver isn’t loaded into memory, making it much more efficient than a solution based on a VM.
How to setup and install WSL
In order to use WSL in windows, you have to set up and install it first to do that we need some configuration and some Linux kernel installed in our machine, Don’t worry this isn’t as tedious as it sounds.
Step 1 — Enable the WSL
WSL is a Windows feature and it is by default off and to enable it you need to open
powershell as administrator and run the following command
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Step 2 — Enable Virtual machine features
After enabling the WSL feature then we need to enable virtualization functionality to run WSL on windows. In order to enable VM features on your machine, you need to run the command given below in Powershell.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Step 3 — Download Linux Kernal Package
Now, you need to download the Linux kernel package. you can download this package by clicking here. or you can also download this package from Microsoft's WSL documentation.
Step 4 — Setting WSL2 as your current version
Open Powershell and run the command given below, you can skip this command. If you don’t want to work with WSL2, you can also work with WSL1. In my case, I would prefer to go for WSL2.
wsl --set-default-version 2
Step 6 — Install your preferred Linux Distro
Open the Microsoft store and search for your preferred Linux distro. I would suggest going for ubuntu because you will find a lot of community support in case you needed any help.
After installing, you need to open ubuntu and for the first time, you have to give a username and a password which will only be for ubuntu and will be used afterward to login and do other
sudo stuff in ubuntu. With all that congrats on installing and setting up WSL on your machine.
I am not against the dual boot, virtual machine instances, or anything else like that. I still use Virtual Machine for some of the Linux applications. The point I am trying to make in this article is that, if you need Linux to just fulfill your developer needs then WSL is the best choice to go for. If you still prefer some other tool and technology that’s totally fine. Choices are our own. With that thanks for reading this article and don’t forget to support me by clicking clap and sharing this with other developers. Cheers!
Top comments (12)
WSL2 used to be more buggy, but it is getting better.
IMO, WSL isn't just a glorified VM, but it also ease the transfer between the VM and Windows.
Best approach? Get a Droplet on DigitalOcean (or Linode), and SSH into it.
Thanks for the tip.
WSL is so great! I recently used it in combination with the WSL Plugin for VS Code - plus, some command line tools are only available for Linux - so it's great to have this opportunity on windows. Thanks for this article ❤️
Thanks for reading ♥
By wsl I can run bash and Microsoft office on same time, without buying another computer
I love wsl, it is great
Glad to know
Imho WSL is just a glorified virtual machine, you should dual boot or get a second machine for running linux
Tip: Use linux and run windows in a vm.
Thanks for the tip.
Indeed dedicated machine is in no competition.
You are right but I and many others can't buy another computer