I am deeply immersed in WSL (Windows Subsystem for Linux), and now thatĀ Ā it is available inĀ , it's a great time to truly explore the available options. A very interesting feature I found in WSL is the ability to 'seamlessly' move data between worlds. This is not an experience you can easily achieve with full virtual machines, and it speaks to the tight integration of Linux and Windows.
Below are some interesting things you can do by mixing peanut butter and chocolate!

Run Windows Explorer from Linux and access your distribution files
When you are in the WSL / bash command line and want visual access to your files, you can run 'explorer.exe .' from your current directory, and you'll get a Windows Explorer window where your Linux files will be delivered to you through the plan9 local network server.

Use real Linux commands (not Cygwin) from Windows
I've written about this before, but now there are aliases for PowerShell functions, Ā from inside Windows.
You can call any Linux command directly from DOS/Windows/whatever by putting it after WSL.exe like this.
C:temp> wsl ls -la | findstr "foo"
-rwxrwxrwx 1 root root 14 Sep 27 14:26 foo.bat
C:temp> dir | wsl grep foo
09/27/2016 02:26 PM 14 foo.bat
C:temp> wsl ls -la > out.txt
C:temp> wsl ls -la /proc/cpuinfo
-r--r--r-- 1 root root 0 Sep 28 11:28 /proc/cpuinfo
C:temp> wsl ls -la "/mnt/c/Program Files"
...contents of C:Program Files...Windows executables can be called/runned from WSL/Linux, as the Windows path is in the $PATH before Windows. All you need to do is explicitly call them with .exe at the end. Here's how 'Explorer.exe' works. You can also do notepad.exe or any other file.
Launch Visual Studio Code and access your Linux applications natively on Windows
You can run 'code.' while in a folder in WSL, and you will be prompted to installĀ . This effectively splits Visual Studio Code in half and runs a 'headless' VS Code Server in Linux with the VS Code client in the Windows world.
You also need to installĀ Ā and . Optionally, installĀ Ā for a better terminal experience on Windows.
Here's a great collection of articles from the Windows Command Line blog.
- Part 1Ā
- Part 2Ā
- Part 3Ā
Here are the benefits of WSL 2
- Virtual machines are resource-intensive and create a very isolated experience.
- The original WSL was quite 'connected' but had significantly lower performance compared to VMs.
- WSL 2 offers a hybrid approach with lightweight VMs, a fully connected interface, and high performance.
Run multiple Linux instances in seconds
Here I use 'wsl --list --all', and I already have three Linux distributions on my system.
C:Usersscott> wsl --list --all
Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)
Ubuntu-16.04
PengwinI can easily launch them and also assign profiles so they appear in my Windows Terminal.
Run X Windows Server on Windows with Pengwin
Ā is a special Linux distribution for WSL that is really cool. You can get it in theĀ . Combine Pengwin with , and you'll have a really great integrated system.
Easily move WSL distributions between Windows systems.
that lets you easily transfer your perfect WSL2 distribution from one machine to n another.
wsl --export MyDistro ./distro.tar
# store it somewhere, Dropbox, OneDrive, somewhere else
mkdir ~/AppData/Local/MyDistro
wsl --import MyDistro ~/AppData/Local/MyDistro ./distro.tar --version 2 That's it. Get the perfect Linux setup synchronized across all your systems.
Use the Windows Git Credential Provider inside WSL
All the mentioned features culminateĀ , where she integratesĀ , turning /usr/bin/git-credential-manager into a shell script that invokes the Windows git creds manager. Brilliant. This would only be possible with clean and tight integration.
Give it a try, install WSL,Ā , and createĀ .
Source: habr.com
