Windows Subsystem for Linux (WSL)

Harisudhan.S
5 min readApr 2, 2024

--

WSL

Windows Subsystem for Linux (WSL) is a feature of Windows that allows you to run a Linux environment on your Windows machine, without the need for a separate virtual machine or dual booting. WSL is designed to provide a seamless and productive experience for developers who want to use both Windows and Linux at the same time.

WSL 2

WSL 2 is the default distro type when installing a Linux distribution. WSL 2 uses virtualization technology to run a Linux kernel inside of a lightweight utility virtual machine (VM). Linux distributions run as isolated containers inside of the WSL 2 managed VM. Linux distributions running via WSL 2 will share the same network namespace, device tree (other than /dev/pts), CPU/Kernel/Memory/Swap, /init binary, but have their own PID namespace, Mount namespace, User namespace, Cgroup namespace, and init process.

A traditional VM experience can be slow to boot up, is 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.

How Does WSL Work?

Windows Subsystem for Linux (WSL) functions by employing a translation layer that converts Linux system calls into Windows system calls, enabling Linux binaries to execute natively on a Windows system. It incorporates a lightweight Linux kernel interface responsible for managing Linux-specific functionalities such as process management and file systems. WSL facilitates seamless integration between Linux and Windows by translating file system calls, enabling access to Windows files from Linux applications, and providing interoperability with Windows components like networking and hardware devices.

With the introduction of WSL 2, which integrates a full Linux kernel into Windows, performance and compatibility are further improved, making WSL a powerful tool for developers needing both Linux and Windows environments. Through a command-line interface, users can interact with WSL, launch Linux distributions, and manage their Linux environment alongside Windows applications, streamlining development workflows and enhancing productivity.

Integrating with Windows

One of the key advantages of WSL is its seamless integration with Windows. Users can access their Windows file system from within the Linux environment, enabling easy file sharing and collaboration between the two operating systems. Additionally, WSL integrates with Windows networking capabilities, allowing Linux applications to communicate with Windows services and vice versa.

WSL also supports the use of Windows tools and utilities within the Linux environment. This includes the ability to invoke Windows executables from the command line, access hardware resources such as GPUs and USB devices, and interact with Windows services through interop capabilities.

Furthermore, WSL provides tight integration with the Windows Terminal, Microsoft’s modern command-line interface. This allows users to manage multiple Linux distributions and Windows command prompts within a single window, streamlining the development workflow.

Installations

To install WSL on your Windows machine, begin by searching for “turn on off windows features” and open it. In the dialog box that appears, scroll down and check the checkbox containing WSL and virtual machine , then restart your device.

Once restarted, open PowerShell and type “wsl — status” to see the installation status, followed by “wsl — version” to check the installed version. You can update WSL using the command “wsl — update.” wsl

Next, visit the Microsoft Store, install any Linux distribution, and launch the application. This will open the Linux terminal on your Windows machine, allowing you to start using WSL seamlessly.

Advantages of WSL

  • WSL provides a native Linux environment within Windows, allowing users to leverage familiar tools and workflows without dual-booting or virtualization.
  • WSL offers high compatibility with Linux applications and libraries, enabling developers to run their favorite tools and utilities seamlessly on Windows.
  • Performance: WSL delivers excellent performance for most workloads, with minimal overhead compared to traditional virtualization solutions.
  • Integration: WSL integrates tightly with Windows, enabling seamless file sharing, networking, and interop capabilities between the two operating systems.
  • Development Workflow: WSL enhances the development workflow by enabling developers to work with Linux and Windows tools side by side, reducing context switching and improving productivity.

Limitations of WSL

  • WSL does not support kernel modules, which may limit its compatibility with certain Linux applications and drivers that rely on kernel-level functionality.
  • While WSL supports running command-line applications and utilities, it does not provide native support for graphical user interfaces (GUIs). However, users can work around this limitation by using X11 forwarding or third-party solutions.
  • While WSL provides access to the Windows file system, file system performance may be slower compared to native Linux installations, especially for disk-intensive workloads.
  • Although WSL supports a wide range of Linux distributions, not all distributions are officially supported by Microsoft. Users may encounter compatibility issues with unsupported distributions or custom configurations.
  • WSL imposes certain resource limitations, such as memory and CPU constraints, which may impact performance for resource-intensive workloads.

Windows Subsystem for Linux (WSL) offers a powerful and seamless integration between Linux and Windows, enabling developers and users to leverage the best of both worlds. With its native Linux environment, tight integration with Windows, and excellent compatibility, WSL has become an essential tool for developers, system administrators, and enthusiasts seeking to enhance their productivity and workflow. While it has certain limitations, the benefits of WSL far outweigh its drawbacks, making it a valuable addition to the Windows ecosystem.

--

--