Codementor Events

WSL - Need Linux but can’t give up Windows?

Published Jun 20, 2021
WSL - Need Linux but can’t give up Windows?

Linux is known for its versatility, power, security, and speed and that’s is why it’s popular in the developer’s community. We all might have felt a need to use a Linux environment during navigating through the developer’s path.

But, at times we can’t give up on windows for some reason or the other. There comes a need for Windows and Linux coexistence on our machine.

You might find different alternative’s like dual-booting your system or using a Linux image on a virtual machine. These are the perfect ways of getting a full-fledged Linux system but at times you might just need just to use the Linux shell to use the best suite of low-level tools like sed, grep, awk piping, and so on.

Well, I have another alternative for you that can solve this purpose with bare minimum resource requirements. Yes, I am talking about WSL.

So, What is WSL?

WSL or Window’s Subsystem for Linux is a feature of Windows 10 that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and apps.

Excited to know this? Well, I was! This was going to solve two problems for me which the other two solutions couldn’t. I tried using a Virtual Machine but it had a very high hardware requirement and the experience wasn't that smooth for me. While when I dual-booted my machine I had to shut down one of the Linux or Windows to access the other (this was frustrating for me!).
So, with the hype created XD lets me navigate you through to set up your WSL.

Enable WSL

  1. Search for Turn Windows features on or off
  2. Enable Windows Subsystem for Linux

001.png
002.png

That’s it! You have got your WSL feature enabled on Windows. Now, we can get Linux and install it.

Get Linux

  1. Search for Windows Store and open it
  2. Click on the search button
  3. Search for a Linux distribution. I am going to install “Ubuntu”
  4. Select a Linux distribution of your choice
  5. Click the install button

003.png
004.png
005.png
006.png
007.png

Launch the Ubuntu and it will install some dependencies. Setup the username and password and you are ready to go!

008.png
009.png
010.png

Congratulations! You have a WSL installed on the top of your windows system where you can run any Linux command, install packages and do anything you do on a Linux shell.

Exchanging files is easy

Now, you might feel a need to be able to connect your Linux and Windows somehow so that you can exchange files between the two.

Let’s check first what’s the “pwd”.

011.png

We are in “/home/<username>”. Let’s navigate out of this directory and explore what else is there.

012.png

We see many directories there. To access our drives we need to move to “mnt” and choose from the partitions we have.

013.png

As you see, we successfully moved into my “d” and this is how we can exchange files between the two systems.

Connecting Visual Studio Code

To access your WSL terminal in VS Code install the “Remote — WSL” extension.

014.png

Now, in the new terminal option select “Ubuntu (WSL)”.

015.png

016.png

If you’ll have a closer look, you are in the “mnt” directory.
That’s pretty it! Now, you are a Window’s power-user, go use your superpowers! 🥳

Discover and read more posts from Ishan Arya
get started
post commentsBe the first to share your opinion
Akshat Arya
3 years ago

😯😯

Show more replies