Bring Linux environment to Windows
Tags: windows, linux, wsl
Published: 2022-02-14 16:37:50

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2i1g3ycx3wmlunk349q4.png) 

- 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](https://www.microsoft.com/store/productId/9N6SVWS3RX71).

- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7coe01lmq45xu7nfc3lo.png)
  
- There are multiple ways of accessing the linux subsystem from terminal but I like using it with Windows Terminals [download link](https://www.microsoft.com/store/productId/9N0DX20HK701) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hppmym9z1ve5klxqlc2k.png)
 
- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fcwdwuohfg4y5gkbxofk.png)
 
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 - WSL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cv7gzwhsv7d0jwexb9s.png)Now, 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.