Cool things you can do with Windows Subsystem for Linux

avatar

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 .

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

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.


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.

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.

Once finished, VS Code will launch.

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.

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.

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 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.


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.

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.


Securely chat with me on Keybase

Why you should vote me as witness



0
0
0.000
4 comments
avatar

Amazing innovation, amazing technology and an amaxing tutorial. Thanks for this bruv. Linux all the way.

0
0
0.000
avatar

Wow. Thanks for taking time to explain this exhaustively 💯🙏. I'm so going to install this. I'd give you some highlights of how it goes

0
0
0.000
avatar

Yeah WSL's great, although I'm still taking my first steps in development. It took me a few days to install python, node, go, setup the variables and update the windows. I'm still getting used to writing commands in a cli ... and the whole abbreviations and shorthands is going to take a while, that and managing all the accounts, libraries and dependencies ...

Development sure is fun, but at least I'm not programming and actually writing things from scratch.

Linux also always amazed me with how clean and simple everything is, if you know all the commands and the basics that is :)

oh and, have you written anything in GO?

0
0
0.000
avatar

I haven't played around with GO, but a lot of people talk good things about it.
If I needed something fairly high level that performance was a problem that JS or Python couldn't do efficiently, I'd look at GO.

0
0
0.000