Jun 15

Welcome to our comprehensive guide on how to leverage the power of Linux on Windows servers using Windows Subsystem for Linux 2 (WSL2). As a Sysadmin, you know that working with servers can be a complex task. You need to be able to manage a wide range of systems, tools, and configurations, often with limited resources.

That’s where WSL2 comes in. This powerful tool allows you to run a full Linux environment directly on your Windows machine, giving you access to all the power of Linux without the need for a separate machine. Whether you’re a seasoned Linux pro or just getting started, WSL2 can help you streamline your workflow and simplify your server management tasks.

What is WSL2?

WSL2 is a relatively new tool that is designed to allow users to run a Linux environment directly within the Windows operating system. This means that you can use Linux commands and tools on your Windows machine without setting up a separate virtual machine or switching between different operating systems.

WSL2 is an improvement on the original WSL, which was introduced in 2016. While the first version of WSL allowed users to run Linux commands on Windows, it was not a true Linux environment, and there were many compatibility issues with different Linux distributions.

WSL2, on the other hand, is a full Linux kernel that runs within a lightweight virtual machine on Windows. This means that it is much more compatible with different Linux distributions, and offers better performance and functionality than the original version.

Some of the key features of WSL2 include:

  • The ability to run Linux commands natively on Windows, without the need for a separate virtual machine or dual boot setup
  • Support for a wide range of Linux distributions, including Ubuntu, Debian, and Fedora
  • Improved performance and compatibility compared to the original WSL
  • Tight integration with the Windows operating system, including file system access and networking

In short, WSL2 is a powerful tool that can help users to extend the capabilities of their Windows machines by allowing them to run Linux commands and tools within a native Linux environment.

Why Use WSL2 for Sysadmin Tasks?

If you’re a Sysadmin working with Windows servers, you know how important it is to have access to the right tools. While Windows has its own set of powerful tools, sometimes you need the flexibility and power of Linux commands. That’s where WSL2 comes in.

With WSL2, you can run Linux commands natively on your Windows machine, without having to set up a separate virtual machine or dual-boot setup. This can save you time and effort, and also help you get more done in less time. Plus, since WSL2 is built into Windows 10, it’s easy to set up and use.

One of the most significant advantages of using WSL2 is the ability to leverage Linux power on Windows servers. Many Sysadmins are already familiar with Linux commands and tools, and using WSL2 allows them to apply that knowledge to Windows servers. This can result in faster and more efficient server management, as well as fewer errors and less downtime.

Another advantage of using WSL2 for Sysadmin tasks is the ability to customize the Linux environment to suit your needs. Since WSL2 supports a variety of Linux distributions, you can choose the one that best fits your workflow and preferences. And since you’ll be working with a Linux environment, you can take advantage of tools like Bash scripts and command-line utilities.

Installing WSL2 on Windows

Before installing WSL2 on your Windows 10 machine, make sure that your system meets the following prerequisites:

  • Your system must be running Windows 10 version 2004 or later
  • You must have the Windows Subsystem for Linux (WSL) feature enabled
  • You must have virtualization capabilities enabled in your BIOS

To enable the WSL feature on your machine, follow these steps:

  • Open the Start menu and search for “Turn Windows features on or off”
  • Select the “Windows Subsystem for Linux” option and click “OK”
  • Restart your computer when prompted

Once you have enabled the WSL feature, you can install a Linux distribution from the Microsoft Store or by using the command line. To install a Linux distribution from the Microsoft Store, follow these steps:

  • Open the Microsoft Store app
  • Search for the Linux distribution you want to install (e.g. Ubuntu, Debian, Kali Linux)
  • Click the “Get” button to download and install the distribution

To install a Linux distribution using the command line, follow these steps:

  • Open a PowerShell or Command Prompt window with administrator privileges
  • Type the following command and press Enter:
    wget -O – https://aka.ms/wsl-debian-gnulinux | sh
  • Replace “debian” with the name of the distribution you want to install (e.g. ubuntu, kali-linux)
  • Follow the prompts to complete the installation

Running Linux Commands on Windows Servers

One of the most powerful aspects of WSL2 is the ability to run Linux commands directly on a Windows server. This means that Sysadmins can leverage the power of Linux tools and utilities without needing to switch to a separate Linux system.

To run Linux commands on a Windows server using WSL2, you will need to open a Bash terminal. This can be done by typing “bash” into the Start menu or by opening a Command Prompt or PowerShell terminal and typing “wsl” to launch the Linux environment.

Once you have opened a Bash terminal, you can start running Linux commands just as you would on a Linux system. For example, you can use the “ls” command to list the contents of a directory, or the “grep” command to search for text within a file.

Wrapping Up

Sysadmins can improve overall system maintenance, expedite server management operations, and troubleshoot and debug effectively by utilizing WSL2. Sysadmins can work more productively and effectively in Windows server environments because of the ability to run Linux command-line tools, scripts, and automation workflows with ease. They may access an accustomed Linux environment inside the Windows operating system thanks to WSL2, which provides a strong and smooth interface between the Windows and Linux ecosystems.

Tags: , ,

May 24

The Windows Subsystem for Linux (WSL) is a feature of the Windows operating system that enables you to run a Linux file system, along with Linux command-line tools and GUI apps, directly on Windows, alongside your traditional Windows desktop and apps. You can now preview Windows Subsystem for Linux (WSL) support for running Linux GUI applications (X11 and Wayland) on Windows in a fully integrated desktop experience. Now we have 2 different WSL here. In this article, let’s try to see how both WSL 1 WSL 2 are different from each other.

Comparing features

As you can tell from the comparison table above, the WSL 2 architecture outperforms WSL 1 in several ways, with the exception of performance across OS file systems, which can be addressed by storing your project files on the same operating system as the tools you are running to work on the project.

WSL 2 is only available in Windows 11 or Windows 10, Version 1903, Build 18362 or later. Check your Windows version by selecting the Windows logo key + R, type winver, select OK. (Or enter the ver command in Windows Command Prompt). You may need to update to the latest Windows version. For builds lower than 18362, WSL is not supported at all.

WSL 2 enables Linux GUI applications to feel native and natural to use on Windows.

  • Launch Linux apps from the Windows Start menu
  • Pin Linux apps to the Windows task bar
  • Use alt-tab to switch between Linux and Windows apps
  • Cut + Paste across Windows and Linux apps

You can now integrate both Windows and Linux applications into your workflow for a seamless desktop experience.

What’s new in WSL 2

WSL 2 is a major overhaul of the underlying architecture and uses virtualization technology and a Linux kernel to enable new features. The primary goals of this update are to increase file system performance and add full system call compatibility.

WSL 2 architecture

VM experience is often slow to boot up, isolated, consumes a lot of resources, and requires your time to manage it. WSL 2 does not have these attributes. WSL 2 provides the benefits of WSL 1, including seamless integration between Windows and Linux, fast boot times, a small resource footprint, and requires no VM configuration or management. While WSL 2 does use a VM, it is managed and run behind the scenes, leaving you with the same user experience as WSL 1.

Integration of Linux kernel

The Linux kernel in WSL 2 is built by Microsoft from the latest stable branch, based on the source available at kernel.org. This kernel has been specially tuned for WSL 2, optimizing for size and performance to provide an amazing Linux experience on Windows. The kernel will be serviced by Windows updates, which means you will get the latest security fixes and kernel improvements without needing to manage it yourself. The WSL 2 Linux kernel is open source.

Increased file IO performance

File intensive operations like git clone, npm install, apt update, apt upgrade, and more are all noticeably faster with WSL 2.

The actual speed increase will depend on which app you’re running and how it is interacting with the file system. Initial versions of WSL 2 run up to 20x faster compared to WSL 1 when unpacking a zipped tarball, and around 2-5x faster when using git clone, npm install and cmake on various projects.

Full system call compatibility

Linux binaries use system calls to perform functions such as accessing files, requesting memory, creating processes, and more. Whereas WSL 1 used a translation layer that was built by the WSL team, WSL 2 includes its own Linux kernel with full system call compatibility. Benefits include:

  • A whole new set of apps that you can run inside of WSL, such as Docker and more.
  • Any updates to the Linux kernel are immediately ready for use. (You don’t have to wait for the WSL team to implement updates and add the changes).

How to install WSL and update to WSL 2

Before installing any Linux distributions on Windows, you must enable the “Windows Subsystem for Linux” optional feature.

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

To only install WSL 1, you have to restart your machine and move on to install your Linux distribution of choice. You can download it from the Windows store.

To update to WSL 2, you must have a running Windows 10, updated to version 2004, Build 19041 or higher.Before installing WSL 2, you must enable the “Virtual Machine Platform” optional feature.

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart your machine to complete the WSL install and update to WSL 2.

To activate WSL 2 you need to update the kernel component. You can do it by visiting here and install the update by following the steps.

You can check the WSL version assigned to each of the Linux distributions you have installed by opening the PowerShell command line and entering the command (only available in Windows Build 19041 or higher): wsl -l -v

wsl --list --verbose

To set a distribution to be backed by either version of WSL please run:

wsl --set-version <distribution name> <versionNumber>

Make sure to replace <distribution name> with the actual name of your distribution and <versionNumber> with the number ‘1’ or ‘2’. You can change back to WSL 1 at any time by running the same command as above but replacing the ‘2’ with a ‘1’.

If you want to make WSL 2 your default architecture you can do so with this command:

wsl --set-default-version 2

Conclusion

Due to the limitations in WSL1 Microsoft re-invented the WSL1 and introduced WSL2 which is available in Windows 10 version 2004 update. Instead of using a compatibility layer which converts Linux system calls to windows system calls, WSL2 offers its own isolated Linux kernel running on a thin version of the Hyper-V hypervisor. And this gives WSL2 much more opportunity to handle things better than WSL1. Hopefully this guide and informations will help you to understand why WSL2 is a better choice over WSL1.

Tags: , ,