Cool things you can do with Windows Subsystem for Linux

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@themarkymark·
0.000 HBD
Cool things you can do with Windows Subsystem for Linux
![image.png](https://files.peakd.com/file/peakd-hive/themarkymark/MVHauj9F-image.png)

While Windows Subsystem for Linux (WSL) gives you a nearly full Linux experience while inside of Windows 10.  There are a few things you can do with it that will make you more productive.

# Explore from here

From the Linux shell, you can open an explorer window by typing in `explorer.exe .`

https://i.imgur.com/kr4IrAA.png

A second later you will see an explorer window open from your current directory.

https://i.imgur.com/ZM36Flc.png

This is really handy when trying to access the Linux part of the file system saving you a lot of time navigating for it.

---

# Run multiple distributions

You are not limited to one distribution.  You can run Ubuntu 18.04 and have 20.04 installed alongside it.  Want to play around with Kali Linux?  Go ahead and install that as well.

Each distribution is very small, for example Kali Linux is only 187Mb.

https://i.imgur.com/fgx4IQm.png

---

# Backup your distribution

Want to create backups of your Linux distribution? 
Want to move your distribution to another machine?

The --export option will allow you to export your distribution to a tar file.

`wsl --export kali-linux ./kali.tar`

**Super easy, barely an inconvenience.**

You can use --import to import a distribution you exported previously.

---

# Open current folder as project in Code

This is my favorite feature of WSL combined w/ VS Code.

You will need to first install the Remote-WSL Extension inside of VS Code.

https://i.imgur.com/ae8vnmF.png

Once installed, you can just type in `code .` in any folder and open it as a project in VS Code.

If this is the first time doing it, VS Code Server files will be installed on the remote.

https://i.imgur.com/o83gtDr.png

Once finished, VS Code will launch.

https://i.imgur.com/bNYHDjd.png

As you can see the folder is opened as a project right in VS Code.

In the bottom left you can see the Remote-WSL module activated.

https://i.imgur.com/Bal6cZR.png

Here is where the real magic happens.

If you go to the VS Code terminal, you are in a bash shell inside of your Linux distribution.

https://i.imgur.com/0vrFT4U.png

It will be as if you are running VS Code directly in your Linux distribution.  As you develop, debug, and run your code, it will all be done in the context of your WSL instance.

**How awesome is that?**

---

# Take advantage of the WSL shared folder

Did you know you can access your local drives from within WSL using `/mnt/c` and whatever other drive letters you have?

You can also access a shared folder specifically for WSL distributions by using `/mnt/wsl`

Got configuration files or scripts you want to share between your Linux distributions?  This is a great way to do it.

---

# Install Docker 

Docker is one of the biggest benefits of WSL 2.0.  It wasn't until WSL 2.0 that Docker became truly useful on Windows.

All you need to do is install [Docker Desktop For Windows](https://hub.docker.com/editions/community/docker-ce-desktop-windows/) to install Docker for Windows and WSL.

Inside the Dockers for Windows settings, you need to turn on WSL 2.0 engine if you want to have the improved support.

https://i.imgur.com/kvDaMEZ.png

---

# Forget your IP!

Previously with WSL you had to check what IP you were using and constantly have to update it on each reboot to connect to any services running on your WSL instance even SSH.

Not too long ago Microsoft added the support to use `localhost` on your Windows machine to connect to your WSL instance.  This short cut won't work if you have two WSL distributions running at once though.

It will allow you easy access to SSH and other services by just doing `ssh localhost`.  You may have problems running SSH on port 22 as Windows 10 now has SSH support as well.  If this is the case, go into your sshd_config file and change the port number.

---

# Pipe commands to WSL

This one is going to blow your mind.  Take a seat, and brace yourself.

By using `wsl` you can launch Linux commands from your Linux distribution right in Windows.

https://i.imgur.com/T6HPOeX.png

https://i.imgur.com/bBipD0U.png

How freaking cool is that?

---

# Access WSL file system from inside of Linux

If you were paying close attention during the first tip, you might have noticed there is now a UNC path for WSL.

`\\wsl$\Ubuntu-20.04\home\mal`

This opens my home folder on my Ubuntu-20.04 distribution from Windows Explorer.

---

<center>Securely chat with me on [Keybase](https://keybase.io/officialmarky)
<center>https://steemitimages.com/DQmcWxV1dpA1eAtw2ipwZiWZkydyVNU5LaLa2Ak1GUnbGmS/The-Marky-Mark.png </center>
# <center>  [Why you should vote me as witness](https://peakd.com/witness-category/@themarkymark/why-you-should-vote-for-themarkymark-as-witness)  </center> #







👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,