Linux and Server 2019: What’s Happening
Windows Substation for Linux (WSL) isn't a brand-new technology, but it's still a feature worth exploring within Windows Server 2019. Let's take a brief look at how to install WSL, use cases for WSL, and what this means for your existing knowledge and skills.
What is the Windows Subsystem for Linux (WSL)?
We can think of the WSL as a compatibility layer that runs between your Windows operating system and a Linux kernel. It is installed as an optional component onto your Windows computer or server (Windows Server 2019 in our example). Once this layer has been installed, you are able to run Linux commands from a Linux command line — just as if you were sitting in front of a native Linux computer.
This opens many possibilities for administrators, developers, and software testers who need to test scripts, programs, or commands quickly — without the need to swap computers or fire up a Linux virtual machine.
Why Bother with WSL?
The first and most obvious reason to use WSL is that it is less of a headache to install it than it is to virtualize a Linux box. This is especially true if you want to run a script against another machine in your environment. Running WSL from your server allows you to access the network just as you would normally, but from the Linux side of things. This translates into a better testing experience because there is little to no configuration needed when running Bash scripts across the network with WSL if it has been set up correctly.
The second reason is apps. Lots of apps. Some flavors of Linux have had the equivalent of an app store since the 90s, which is fully accessible from the command line. This forward-thinking software delivery system has found its way into modern Linux distributions, and therefore WSL, too.
In Ubuntu WSL, for example, a simple command lets your system update all file dependencies on your system before installing the requested app from a repository on the internet.
Progress is automated to a large extent, aside from the occasional user prompt to press the 'Y' and RETURN keys to accept the installation. Better still, it is fully transparent, so you can watch each step of the installation unfold in front of you in the command line. WSL works exactly the same way, so the massive catalogue of packages and apps is available to you without any hassles.
A third reason to use WSL is to iImpress your friends and colleagues with your new-found Linux knowledge. Launching a Bash session from a Windows Command Line is quite a surreal experience at first, too.
Finally, there's the issue of security. Before Microsoft had a reliable patching cycle, it was Linux systems that were seen as the most secure option to host critical services within companies and organizations. Updating the entire operating system from the command line is a simple task,with all dependencies looked after automatically. WSL is the same. This makes it a safe option to use, provided you keep your systems updated.
So, what are we waiting for? Let's get installing!
How to Install WSL with PowerShell
1. To get started we need to fire up a PowerShell session with elevated permissions. Type:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Your Server will reboot after this step, so take all the normal precautions and save your work.
2. Next, you will need to choose your flavor of Linux. The 'best' distribution or distro will vary from person to person, but for our example we'll install Ubuntu.
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile Ubuntu.appx -UseBasicParsing
This starts the process and can take a while depending on your internet connection.
We downloaded the file to c:\windows\system32
Step 3. We need to convert the APPX file to a zip archive and extract its content.
Step 4. If you want to add the Ubuntu executable to your environment, then type in the following command: c:\windows\system32\ubuntu\ubuntu1604.exe
Step 5. Now that we have our Linux system installed, let's look at what we can do with it. Most system administrators take advantage of the fact that Linux commands are needed.
To run it, open a cmd window with elevated admin rights. Then simply type wsl and you will be logged in.
Why Should You Use WSL
Now it's time to look at a few scenarios.
Scenario 1: Your Favorite Linux Apps at Your Fingertips
Perhaps one of the most commonly used apps in Linux for a system admin is ssh. Using this secure shell connector gives you an easily accessible alternative to server 2019's native ssh client. With ssh you can connect securely to network appliances such as routers and switches, IoT devices such as biometric readers and cameras.
If you have a lot of configuration work to do then it makes sense to run ssh in this type of configuration. If you are a Linux veteran, then you will find old favorites like vi are accessible for all your command-based text editing. You can even set up cron to run scheduled tasks in the background if you want to. There is a bit of setup involved, but it works.
Scenario 2: Development and Testing
This is probably the most common reason for using the WSL. If you program in languages such as Go, NodeJS, python or bash then this is an excellent way to write programs and test without having to worry about connectivity issues between a virtual Linux machine and your testing environment.
If you use Git for your commits and code management then you can also get it running in WSL. Vs Code has a tutorial to help you get set up in no time at all. There are some limitations to using this Vs Code on WSL, and most people have started using WSL 2 for dev work. But this article is intended to help showcase what Windows Server 2019 is capable of. Hopefully this will help you to get WSL set up for yourself so that you can use it whenever you are logged onto your Windows Server 2019 system.
Scenario 3: Linux Administration
This is a fine option if you have a mixed environment with both Windows and Linux installed across your infrastructure. You can connect quickly and easily to networked devices by using ssh, while not needing to swap computers to run different sets of scripts.
This turns your computer into a multi-purpose admin machine. Running your Linux applications through WSL can save you a lot of system resources, too, because you won't be hosting a fully-fledged VM on your Windows Server.
Wrapping Up
Microsoft has gone to great lengths over the years to ensure that PowerShell is a robust and powerful tool for Windows machines. Therefore, the inclusion of Bash is largely seen as a side-by-side implementation, at least according to Joey Aiello, Microsoft's PowerShell Program Manager.
This means that PowerShell knowledge is not going to be irrelevant any time soon. Instead, it benefits anyone who has experience in Bash style scripting — while leveraging the modern and integrated controls that PowerShell brings to the table.
delivered to your inbox.
By submitting this form you agree to receive marketing emails from CBT Nuggets and that you have read, understood and are able to consent to our privacy policy.