Windows Subsystem for Linux has emerged as a serious tool for development, but it’s also useful for running the vast networking Linux toolkit. Modern versions of Windows, building on the foundation of Windows NT, also have their own networking tools.
You may be wondering which set of tools you should focus on if you’re running Linux under WSL. With the ability to run real Linux commands, the choice of Windows or Linux is becoming clearer. It makes more sense to access the rich networking toolkit from WSL.
Linux Is Standard for Servers
While Linux still only represents a small number of desktop computers, it dominates in server computing. A statistic from ZDNet in 2015 proved that 96.3 percent of the top 1 million web servers in the world use Linux. Of the world’s top 500 supercomputers, 100 percent of them run Linux. That’s right, all of them.
Because Linux is so ubiquitous in server computing, if you’re serious about wanting to learn about networking, you’ll want to become familiar with Linux if you aren’t already.
In the past, the way to run Linux and Windows on the same machine was to install a dual-boot system, but this can take time. It also requires disk space and there’s the need to switch system. Tools like Cygwin have also been available but they’re just ports of Linux commands to Windows and don’t work exactly the same.
Virtual machines allow Linux and Windows to run at the same time but a VM can consume a lot of resources and it’s sometimes difficult to integrate the host and guest systems.
WSL eliminates the need to switch contexts and lets you be productive immediately.
Set Up Windows Subsystem for Linux
If you’re just learning about networking, it’s easy to set up WSL on a Windows machine and not have to contend with installation, multibooting, or having to contend with a new interface on top of a new operating system. You can have your familiar Windows environment while you get hands-on with networking tools.
If you are already a seasoned Linux user, WSL also has a lot to offer you. You can run your familiar networking tools right in Windows, and you’ll be able to mix and match Windows and Linux commands on the same command line. You can’t do that in a virtual machine or standalone Linux installation.
In any case, you’ll find the same environment on WSL that you would find on a Linux server. This means that commands will work the same way on both systems. You can follow documentation that’s meant for Linux.
As you gain confidence in your Linux skills, you’ll be able to apply what you learn to full-fledged Linux installations.
Open Source Toolkit
The main reason for using WSL is to gain access to the open source networking toolkit that Linux offers.
You might be building a web application, so you’d want to have test web and database servers. You can install the Apache web server and MariaDB database server, both of which are used to run lots of websites in the real world.
You can troubleshoot network connections with ping, tracepath, MTR, and dig deeper into remote servers with nmap.
The point is that you’ll have access to the same tools you’d find on a Linux machine and they’ll work the same way. That means that going from Windows to Linux and back again is seamless.
While many of these tools have native Windows ports, it’s often the Linux versions that get priority from the developers. This means that if you run into any problems with the Windows versions, most likely the problem is going to be that you’re using Windows.
WSL runs native Linux binaries, so that means you’ll be running the exact same version you would on a Linux machine. Now that WSL2 uses a virtualized Linux kernel, it’s more like a standard Linux box in terms of behavior.
That means that tools will work the way open source developers expect them to.
Integrating Windows and Linux
One of the best parts of WSL is the ability to mix and match Windows and Linux from the same command line, whether in Linux or PowerShell.
To access the Linux filesystem from Windows, simply type into the shell:
$ Explorer.exe .
This will open up Windows Explorer to the current directory. You can substitute any Linux directory for the “.” and open it in Explorer.
You can also run any Windows command in Linux by appending .exe to it. If you wanted to edit your .bashrc in Notepad, for example, type:
$ notepad.exe .bashrc
You can also access the Windows filesystem from Linux from the /mnt/[drive letter] directory. If your Windows drive is C:, it would be /mnt/c.
Going to the Windows side, the wsl command will run anything appended to it in your WSL Linux installation and return the result in PowerShell:
wsl ls
This command will give you a Linux directory listing.
Why would you want to mix and match Windows and Linux commands? You might simply prefer a command in one system over the other. The Windows tracert and Linux tracepath commands both create traceroutes that follow the routes packets take to a server, but display the results differently.
Tracepath Linux command run in WSL from PowerShell:
Windows Tracert command in Linux:
You might already have an OpenSSH key generated for Windows. If you wanted to use the Linux version, you’d have to create another key. With WSL, you can just use your existing key. You’d just type this in WSL:
ssh.exe username@server
Being able to run different operating system commands from the same command line is nothing short of amazing. You have the ability to run two different systems as one without having to dual boot or use a virtualization application. WSL is just an incredibly flexible solution.
A Networking Powerhouse
With WSL, you don’t have to choose between Linux or Windows to unleash the networking power of the latter on your system. You can keep your existing desktop and issue Linux commands in Windows, and Windows commands in Linux.
It’s a powerful alternative to a dual-boot and virtual machines. With more improvements for WSL in the pipeline, including the ability to run graphical applications, it looks like WSL will only get better with time. Whether you’re an old hand or just getting into networking, why not take the plunge?