DEV Community

Cover image for Bring Linux environment to Windows
Kaushal
Kaushal

Posted on • Updated on

Bring Linux environment to Windows

Hey there.
When a project is built up for a specific environment and you can't execute it in another, it's a nightmare for a developer. For example, the majority of the projects are configured to run on a Linux environment. As a result, setting up VirtualBox on a Windows machine for Linux is a simple option (Ubuntu). However, this is incredibly slow because it has access to a limited quantity of primary memory, which can hinder our performance.

I discovered a Windows feature, which is an excellent method for running a Linux environment on Windows, WSL(Windows Subsystem for Linux) is a feature provided by Windows.

The steps to do so are outlined below.
  • Search for Turn Windows features on or off in your Windows machine, which gives you a screen something like this.
    Turn Windows features on or off screen image

  • Click on the checkbox called Windows Subsystem for Linux and press OK. This will restart your computer so that WSL can be installed. There is another way to do it, that uses the command line, but this one is easiest.

  • Install Ubuntu from the Microsoft store so WSL can assess the subsystem(it require an environment to run the WSL). I would recommend the latest version of Ubuntu(20.04), which you can install from this link.

  • After the Ubuntu installation is complete, please open it and complete the basic setup process, such as setting up a username and password. At the end of the process you will see a screen like below. Close the Ubuntu window.
    ubuntu

  • There are multiple ways of accessing the linux subsystem from terminal but I like using it with Windows Terminals download link for Windows Terminals from the Microsoft Store.

  • By default, when you open Windows Terminal after installation, it will launch Windows PowerShell. By clicking the chevron symbol, you may see all of the available terminals on your system.
    Choose the third option to open unbuntu terminal.
    windows terminal

  • If you run the command ls, you will see your Windows files and folders from the Ubuntu terminal and can access them. In my case, ls command output

Hurry, we set up the WSL successfully!

WSL includes several ridiculous features:

If your local server is running on Ubuntu, you can access it from localhost; you can browse the React.js project from localhost even though the server is running on Ubuntu terminal vice versa, for example. Similarly, If you have a database server(MongoDB, MySQL, etc.) running on Windows, your backend server can access that DB server from the Ubuntu environment.

A tip to open your Vistual Studio Code using Ubuntu host. Install Remote - WSL extention on your VS Code.
Remote - WSLNow, navigate to the directory you wish to access in VS Code and type the command 'code .' if you run this program for the first time on Ubuntu, it will install a few packages that allow you to open VS Code.

Top comments (0)