DEV Community

Cover image for Windows is not that bad for software development
Mohamad Ashraful Islam
Mohamad Ashraful Islam

Posted on

Windows is not that bad for software development

Today it's not about virtualbox/vmware. It's a new Windows 10 feature. They called it WSL(Windows Subsystem for Linux)

Originally Posted on HERE

What is WSL?

Already told Windows Subsystem for Linux. Windows made sure to install Linux operating system inside the Windows environment without extra virtualization software(Virtual Box, VmWare, ...). So, How they did that?? That's burning question. Today I'll not go that way. But one thing I can tell that is, they slightly modified the kernel to fit with windows. Isn't it awesome?? YES! I am really exited to share about it.

What we are going to cover today?

  • Prerequisites
  • Enable WSL.
  • Install Ubuntu (22.04 Maybe).
  • Set WSL Resource.
  • Install Docker on Ubuntu.
  • VSCode WSL development.
  • Intellij IDE WSL development.

Prerequisites

You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.

To check your Windows version and build number, select Windows logo key + R, type winver, select OK.

Enabling WSL

You can enable from GUI as well as from Powershell. I always prefer the hard way(command line). So, Run the following commands on Powershell.

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

Enabling the Virtualization Technology

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Enter fullscreen mode Exit fullscreen mode

Now you need to restart the machine.

Install WSL Update

Downthe the update installer from here and Run the installer.

Set WSL2 as default WSL version.

wsl --set-default-version 2
Enter fullscreen mode Exit fullscreen mode

Update existing distribution (if any)

wsl --set-version <distribution name> 2
Enter fullscreen mode Exit fullscreen mode

Install Ubuntu (22.04)

There are several ways to install the OS in WSL. You can download from the Windows Store. This is the hassel free process. Once installed you will be able to login using your given password. Don't afraid, there is no UI. Only command line like Ubuntu Server :)

Now open Powershell again,

wsl -l -v 
Enter fullscreen mode Exit fullscreen mode

You will get something like following,
WSL Version

Set WSL Resource

Yes. You can still have chance to modify your resource allocation. Otherwise your windows will decide to do so. The process is pretty simple. You need to create a file to a specific location.

Open the file,

notepad "$env:USERPROFILE\.wslconfig"
Enter fullscreen mode Exit fullscreen mode

Add these lines to the editor and save it.

[wsl2]
memory=4GB  
processors=4
Enter fullscreen mode Exit fullscreen mode

You can read the microsoft's document for more configuration.

Now login to the ubuntu again, with Powershell/CMD whatever shell you have.

wsl
Enter fullscreen mode Exit fullscreen mode

WSL Login

Install Docker on WSL(Ubuntu)

It's not mandatory. So, don't push yourself into Docker if your are not a Docker guy.

Installing Docker is same guide as ubuntu. You can follow the official Docker docs OR blindly follow me. Run the following commands on the Ubuntu's terminal not Powershell.

  1. Update the apt package index and install packages to allow apt to use a repository over HTTPS:
$ sudo apt update
$ sudo apt install \
   ca-certificates \
   curl \
   gnupg \
   lsb-release
Enter fullscreen mode Exit fullscreen mode
  1. Add Docker’s official GPG key:
$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Enter fullscreen mode Exit fullscreen mode
  1. Use the following command to set up the repository
$ echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Enter fullscreen mode Exit fullscreen mode
  1. Install Docker Engine
$ sudo apt update
$ sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Enter fullscreen mode Exit fullscreen mode
  1. Start the docker and check
$ sudo service docker start
$ sudo service docker status
Enter fullscreen mode Exit fullscreen mode
  1. Test your docker installation
$ sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Output:
WSL Docker Hello

So, Docker is working.

Incase any Network issue from WSL

$ echo -e "[network]\ngenerateResolvConf = false" | sudo tee -a /etc/wsl.conf
$ sudo unlink /etc/resolv.conf
$ echo nameserver 1.1.1.1 | sudo tee /etc/resolv.conf
Enter fullscreen mode Exit fullscreen mode

IPTables related issues

I found some people have iptables related errors. So I recommend the following command and choose legacy

$ update-alternatives --config iptables
Enter fullscreen mode Exit fullscreen mode

Setting up VSCode

Actually there is nothing to setup. Trust me and do the following things,

  • You just need to install an extension. You can get it from here.
  • Create a project on WSL(ubuntu)
  • On the bottom left corner you will see remote development button.
  • Select New WSL Window
  • Open the project from WSL(Ubuntu) VSCode

Now it's all yours.

Setting up Intellij IDE (Pycharm in my case.)

  • Using Intellij IDE (Pycharm) codes stays on the windows machine.
  • Interpreter(Environment) will be just shared from WSL. The step by step guide is here.

Conclusion

I've talked too much today. But it made me to do so. But, Why I am writing this post?

In short, After 7-8 years I have been trying windows 10. I am so pleased to see the WSL and how it works. So, I thought people may like it too. Thank you.

Top comments (11)

Collapse
 
nlxdodge profile image
NLxDoDge

While WSL is really nice if it really doesn't work. Docker is also a good replacement for this.
Also for windows you can use tools like pyenv-win to easily switch Python environments if that floats your boat.

I did use WSL with Ubuntu when I was at my old job programming Ruby. Because lots of things didn't work right on Windows. But they didn't use Docker yet in the company when I arrived. So I used WSL as well.

Collapse
 
ashraful profile image
Mohamad Ashraful Islam

Here I just wanted to show How things work on WSL over windows. I felt so cool with it. Personally I use Linux and Mac on my home and office.

Collapse
 
nlxdodge profile image
NLxDoDge

Nice. Might I ask which linux distro you work with? I want to try one as well but can't pick one.

Thread Thread
 
ashraful profile image
Mohamad Ashraful Islam

I have worked with Ubuntu, Mint, Manjaro, Elementary. Currently I am using Mint for personal day to day use

Collapse
 
victoriyaalmeida profile image
Victoria Almeida • Edited

As an analyst from cipd assignments help IE, depending on your need if you want to work with some light Linux applications then you are just good to go with Linux shell being installed in your windows powered machine but for Docker or something big you need VM instead of WSL.

Collapse
 
ashraful profile image
Mohamad Ashraful Islam

Thanks for the information

Collapse
 
isabelleross profile image
isabelleross

I completely agree with you, Ashraful Islam. Just like we believe that Microsoft is indispensable, students of knowledge also heavily rely on Microsoft products for various purposes, such as cipd assignment writing services and more. Just as we benefit from Google's products, Microsoft proves to be equally helpful in development.

Collapse
 
ashraful profile image
Mohamad Ashraful Islam

Thank you

Collapse
 
gabrielprogramerx profile image
Gabrielprogramerx

Windows is a very good operating system. Especially when it comes to programming. Windows 11 deserves special attention here. If someone is looking for a cheaper license, I recommend this store: royalcdkeys.com/products/windows-1...

Collapse
 
ashraful profile image
Mohamad Ashraful Islam

Thanks. But it's retail version of the license.

Collapse
 
reemsultan profile image
Reem Sultan

That's great, you are right. WSL helps users of Linux-first technologies (like Ruby and Python) and web developers use their Windows tools and maintain consistency between development and production environments. Here such as Assignment help UAE In the same way that we gain from Google's goods, Microsoft too contributes to progress. Just like we benefit from Google's products, Microsoft also advances society.